LostRoninYT
LostRoninYT

Reputation: 11

How do I restart a python script with a command

So, I've been having troubles with restarting a script within itself. I'm making a simple program and I want to have a choice for example:

print ('would you like to make another calculation')

choice3 = input(' Choose: [Y], [N]')

if choice3.lower() == 'y':
    print ('OK!')
    time.sleep(3)

and I want to have it restart right there. If anyone could help me out, thanks... I really appreciate it

Upvotes: 0

Views: 2529

Answers (1)

SatanDmytro
SatanDmytro

Reputation: 537

You can do this using loop:

while True:
    print ('would you like to make another calculation')
    choice3 = input(' Choose: [Y], [N]')
    if choice3.lower() == 'y':
        print ('OK!')
        time.sleep(3)
    else:
        break

Upvotes: 2

Related Questions