0

Hey Stackoverflow community, I'm quite new to coding but recently I have taken an interest in python. Below I have a sample script that's similiar to what I'm writing. I can't find anything basic so please keep it simple :D Also, how would I do this with multiple if-elif-else?

print('Sample "Console" :D')
console = input('-> ')
if console == 'Restart':
    print('Restarting')

If I want to have the code loop from the begining what do I do? Please do a quick rewrite of the code with the loop.

1 Answer 1

1

You can Use a while loop.

while True:
    console = input('->')
    if console != 'Restart' :
        break

Hope it helps. Happy Coding :)

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks San! Can I ask what the ! mean?
'==' means equal and != means 'not equal' .. so it will check for the input string, if it is not equal to 'Restart' it will exit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.