7.8 使用 or

    or 关键字也是用来把多个条件放在一起。如果使用 or,只要任意一个条件为真,就会执行代码块。

    color = raw_input("Enter your favorite color: ")
    if color == "red" or color == "blue" or color == "green":
    print "You are allowed to play this game."
    else:
    print "Sorry, you can't play the game."

    空标题文档 - 图1