+ 1

how do you return the loop to the beginning if the input is incorrect or done?

import random import time """any help on the matter would be appreciated, I'm new to all of this and this took me a while to make""" a = ("yes") b = ("no") c = ("as you wish ") for i in range(1): die_twenty = random.randint(1, 20) name = input("Greetings limp wristed traveller what is your name?") print("Welcome " + name + "!" " you lazy guttersnipe") roll = input("would you like to roll the dice?") if roll == b: print("why are you even talking to me then.") time.sleep(1) print("...") time.sleep(1.5) print("away with you and your filthy meat beaters") elif roll == a: print(" as you wish ") time.sleep(1) print(die_twenty) time.sleep(.5) else: print("why are you even here... come back later and try again")

21st Mar 2018, 3:16 PM
Jeremy Sax
Jeremy Sax - avatar
2 odpowiedzi
+ 2
Nicely done! you almost had it complete! Here's one way to loop the question till one of the options is entered: while True: roll = input("would you like to roll the dice?") if roll == b: print("why are you even talking to me then.") time.sleep(1) print("...") time.sleep(1.5) print("away with you and your filthy meat beaters") break elif roll == a: print(" as you wish ") time.sleep(1) print(die_twenty) time.sleep(.5) break else: print("why are you even here... come back later and try again") Hope this helped :)
21st Mar 2018, 3:29 PM
Just A Rather Ridiculously Long Username
0
It did thank you very much :)!!!
21st Mar 2018, 10:46 PM
Jeremy Sax
Jeremy Sax - avatar