我正在尝试教我儿子如何编程,我给了他一个我自己无法完成的挑战。
他必须提示用户输入 A、B 或 C。根据他们的选择,他将打印一些结果和其他内容。当我们完成这项工作时,我正在尝试进行一些错误处理并检查输入不是 A、B 或 C 的情况。下面列出了代码。我当然感谢您提供的任何指导。
print "************************************************************"
print "* *"
print "* Welcome to the cinemas *"
print "* *"
print "************************************************************"
print "* *"
print "* What movie would you like to see ? *"
print "* *"
print "* A) Star Wars *"
print "* B) Bourne Identity *"
print "* C) The Hunger Games *"
print "* *"
print "************************************************************"
movie=raw_input()
while(movie!="A","B","C"):
print "************************************************************"
print "* *"
print "* Welcome to the cinemas *"
print "* *"
print "************************************************************"
print "* *"
print "* What movie would you like to see ? *"
print "* *"
print "* A) Star Wars *"
print "* B) Bourne Identity *"
print "* C) The Hunger Games *"
print "* *"
print "************************************************************"
movie=raw_input()
print "************************************************************"
print "* *"
print "* How many tickets would you like ? *"
print "* *"
print "************************************************************"
quantity =input()
cost = 7.5
if movie =="A":
print "You are seeing Star Wars"
price = cost*quantity
print "You owe ", price
elif movie =="B":
print "You are seeing Bourne Identity"
price = cost*quantity
print "You owe ", price
elif movie =="C":
print "You are seeing The Hunger Games"
price = cost*quantity
print "You owe ", price