Nov-03-2017, 07:11 PM
(Nov-03-2017, 06:46 PM)Lux Wrote: You have the right idea with a 'while' loop, but you want your code to repeat until they give an acceptable answer. If you're only looking for "Forward", your code might look like this:
while not dir1 == "Forward": dir1 = input("Which way do you want to move?")This code will repeat until the user enters "Forward"
(Nov-03-2017, 06:48 PM)nilamo Wrote: When you want something to happen more than once, then you want a loop. In this case, a while loop is probably right. Something likewhlie True: direction = input("Where to, boss? ").lower() if not direction: print("You can't go nowhere.") elif direction == "forward": print("CHARGE!")
Ah interesting, that makes sense, thanks very much to you both for the swift responses. I mean I want to eventually get to the point where multiple different answers can be given to a single question, like if you were writing an adventure story for example, but that's definitely something I will experiment with in the meantime. Just baby steps, at the moment.