Clemens Dotson
Clemens Dotson

Reputation: 85

How to restart a python script using IDLE Basic

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.

Upvotes: 0

Views: 130

Answers (1)

Strik3r
Strik3r

Reputation: 1057

You can Use a while loop.

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

Hope it helps. Happy Coding :)

Upvotes: 1

Related Questions