每天一个python 小案例――if else

这是一个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"


执行结果

spacer.gif wKioL1MyQv_gbUYuAADe37SwX4g910.jpg
spacer.gif
spacer.gif


你可能感兴趣的:(else,if,elif)