Conditions


#1

While creating a program how do you create a condition within a condition, I mean can you actually do that.

for example

def example():
answer=raw_input("where do you want to go?")
if answer=="left":
print "you have turned left, now go straight"
#now if you wanted to make another condition that do you want to go straight or not under the same 'if' condition what to do???
if answer== "right":
print "you have gone right"
example()


#2

you can simple nest if conditions:

if condition:
    if condition:

#3

But what to do if you want it to take input again???


#4

that is a different question alltogether? idealy, use a while loop


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.