print("Welcome in American Roulette")
rules=("blabla rules of roulette")
import random
while True:
print("Enter 'rules' to show rules")
print("Enter 'play' to play the game")
print("Enter 'author' to show info about creator")
print("Enter 'quit' to end the program")
user_input=input()
if user_input=="quit" or "Quit":
break
elif user_input=="rules" or "rule" or "Rules" or "Rule":
print(rules)
elif user_input=="play":
bet=int(input("Place your bet\n"))
amount=float(input("How much you want to bet?"))
spin=random.randint(0,36)
if bet>36:
print("You need to bet number beetwen 0 and 36!")
elif bet<0:
print("You need to bet number beetwen 0 and 36")
elif spin==bet:
print("You won",amount*35)
print("Now you have",start-amount+amount*35)
else:
print("You lose")
elif user_input=="author":
print("Jacob X")
else:
print("Unknown command")
答案 0 :(得分:0)
您的第一个if
应该是:
if user_input.lower() == "quit":
break
或
if user_input == "quit" or user_input == "Quit":
break
您缺少条件中的第二个user_input
。由于"Quit"
不是空字符串,因此它的值为True
,并且while循环将中断。
此elif
的情况也是如此:
elif user_input=="rules" or "rule" or "Rules" or "Rule":