这是一个if elif else的小练习
#!/bin/usr/python
print "You enter a dark room with two doors,do you go through door #1 or door #2"
door = raw_input(">")
if door == "1":
print "ok"
bare = raw_input(">")
if bare == "1":
print "true"
elif bare == "2":
print "false"
else:
print "true and false"
elif door == "2":
print "no"
insantiy = raw_input(">")
if insantiy == "1" or insantiy =="2":
print "not or delete"
else:
print "not and delete"
else:
print "not delete ok no"
执行结果
转载于:https://blog.51cto.com/5471815/1384363