I tried to make a way to let the user choose to which piece of the program it would go, i first tried for but later went and used if, this is the code:
while True:
whichcode = 1
#set the variable for the first time.
while True:
if whichcode == 1:
print "code nr one"
print "where to go?"
x = raw_input("1 or 2 or 3? ")
if x == 1:
whichcode = 1
if x == 2:
whichcode = 2
if x == 3: #let the user choose
whichcode = 3 #which piece of code it should go to.
if whichcode == 2:
print "code nr 2"
print "where to go?"
x = raw_input("1 or 2 or 3:? ")
if x == 1:
whichcode = 1
if x == 2:
whichcode = 2 #let user choose again.
if x == 3:
whichcode = 3
if whichcode == 3:
print "code nr 3"
print "where to go?"
x = raw_input("1 or 2 or 3:? ")
if x == 1:
whichcode = 1
if x == 2:
whichcode = 2 #and again.
if x == 3:
whichcode = 3
(I now get zero syntax errors, so thats not a problem anymore.)
but when i run it does nothing, i can type, but it stays at typing, it doest print anything, and when i use ctrl+c to get out if the loop is says that is has stayed at line 1, the first while True. does anyone know why?
(this is what is says after i ctrl + c out of the loop:)
^CTraceback (most recent call last):
File "forloops.py", line 1, in <module>
while True:
KeyboardInterrupt