所以我是新手,我正在尝试为剧院票务系统编写程序。这只是我试图找出如何使用 while ,所以如果输入错误,我可以阻止程序执行下一步,这是 while 代码:(我在某个地方得到了它,我改变了一些东西)
Movie_is = "a"# i want to assign more than one string like "A","b","B" etc
movie_slection = True
while movie_slection:
Choose=raw_input("Choose your movie by typing the correct letter")
if Choose != Movie_is:
print 'Wrong input'
movie_slection = False
elif Choose == Movie_is:
print 'Your movie is :'
else:
print 'Wrong input.'
print 'Done'</i>
这是我想在其中使用第一个代码的另一个代码,如果我输入 d 它会进入门票选择:
print "a.Fight Club (1999)", "b.Freaks (1932)","c.Barton Fink (1992)"
Movie_is=raw_input("Choose your movie by typing the correct letter")
if Movie_is == "a" or Movie_is== "A":
movie = "Fight Club (1999)"
elif Movie_is == "b" or Movie_is=="B":
movie = "Freaks(1932)"
elif Movie_is == "c" or Movie_is== "C":
movie = "Barton Fink (1992)"
else:
movie = "You have entered a wrong letter ,\n note:this application is case sensitive"
print " Selected Movie : ", movie
# the tickets selection
Tickets_is=raw_input(" Select Tickets: a.(Adult) b.(Children) c.(Senior) d.(Student)")
if Tickets_is=="a" or Tickets_is== "A" :
tickets="""
|| SCREEN ||
1 2 3 4 5 6 7 8 9 10
"""
elif Tickets_is == "b" or Tickets_is=="B":
tickets= """
|| SCREEN ||
1 2 3 4 5 6 7 8 9 10
"""
elif Tickets_is == "c" or Tickets_is== "C":
tickets= """
|| SCREEN ||
1 2 3 4 5 6 7 8 9 10
"""
elif Tickets_is == "d" or Tickets_is== "D":
tickets= """
|| SCREEN ||
1 2 3 4 5 6 7 8 9 10
"""
else:
tickets= "You have entered a wrong input , please type a valid seat number"
print "Seats: ",tickets </i>
提前致谢 。