I wrote a short program that stores user input into a list, asks if there's anything else that needs to be entered, and eventually selects an item out of the list.
The problem I have is that if the user puts anything other than y or n when asked if there is anything else, it'll exit out of the if block and continue. Is there any way that I can make it loop back without using a while statement?
The problem I have is that if the user puts anything other than y or n when asked if there is anything else, it'll exit out of the if block and continue. Is there any way that I can make it loop back without using a while statement?
Code:
toDo = []
import time
import os
import random
def welcome():
print "What is something you wanna do?"
firstToDo = raw_input()
toDo.append(firstToDo)
def otherChoices():
Running = True
print "Do you have any other choices?"
nextThing = str.upper(raw_input("Y or N: "))
if nextThing == "Y":
while Running == True:
print "What else do you want to add?"
print
addThing = raw_input()
toDo.append(addThing)
print addThing, "has been added to the list."
print "Is there anything else?"
print
moreChoices = str.upper(raw_input("Y or N: "))
if moreChoices == "Y":
Running = True
elif moreChoices == "N":
Running = False
nextThing = "N"
else:
Running = True
elif nextThing == "N":
Running = False
else:
pass
def choose():
print "Now we'll decide what to do."
print "..."
time.sleep(2)
print "..."
time.sleep(2)
print random.choice(toDo)
raw_input()
welcome()
if len(toDo) > 0:
otherChoices()
choose()
Comment