0
飛行機に十分な座席がない場合、飛行機を予約することはできませんが、前回のコード行(8行目)に戻りたいと思います。前の行を実行していますか?
while True:
if b == maxpass and booking == "b" or booking == "book":
print ("Sorry but the flight you want is currently fully booked. Sorry for Inconviniance")
print ("Welcome to Flight Booking Program")
print ("Please enter the flight number you want to book/cancel with? (Case Sensitve)")
flight = input()
繰り返しています。ここで
は、コードの残りの部分である:
# b means bookings, fn means Flight Number
b = 0
maxpass = 68
minpass = 0
fn = "FNO123"
amount = 0
seatsremain = 68 - b
print ("Welcome to Flight Booking Program")
print ("Please enter the flight number you want to book/cancel with? (Case Sensitve)")
flight = input()
while flight != "X":
seatsremain = 68 - b
while True:
if flight == fn:
print ("There are currently", seatsremain, "seats remaining")
break
else:
print ("ERROR")
print ("Not a valid flight number! Remember input is CASE SENSITIVE")
print ("Welcome to Flight Booking Program")
print ("Please enter the flight number you want to book/cancel with? (Case Sensitve)")
flight = input()
print ("Would you like to book or cancel your flight?")
booking = input().lower()
while True:
if b == maxpass and booking == "b" or booking == "book":
print ("Sorry but the flight you want is currently fully booked. Sorry for Inconviniance")
print ("Welcome to Flight Booking Program")
print ("Please enter the flight number you want to book/cancel with? (Case Sensitve)")
flight = input()
else:
break
if booking == "c" or booking == "b" or booking == "book" or booking == "cancel":
if booking == "b" or booking == "book":
print ("How many seats are you booking?")
while True:
try:
amount = int(input())
if amount <1 or amount >seatsremain:
print ("ERROR")
print ("You must book at least 1 seat and not exceed the maximum amount of seats avaliable")
print ("There are currently", seatsremain, "seats remaining")
print ("How many seats are you booking?")
else:
b = b + amount
print ("Your flight has been Booked!")
print ("Welcome to Flight Booking Program")
print ("Please enter the flight number you want to book/cancel with? (Case Sensitve)")
flight = input()
break
except ValueError:
print ("You must enter a valid number!")
else:
if booking == "c" or booking == "cancel":
print ("How many seats are you canceling?")
while True:
try:
amount = int(input())
if amount <1 or amount >b:
print ("ERROR")
print ("You must cancel at least 1 seat and not exceed the minimum amount of seats avaliable")
print ("There are currently", seatsremain, "seats remaining")
print ("How many seats are you cancelling?")
else:
b = b - amount
print ("Your flight has been Cancelled!")
print ("Welcome to Flight Booking Program")
print ("Please enter the flight number you want to book/cancel with? (Case Sensitve)")
flight = input()
break
except ValueError:
print ("You must enter a valid number!")
else:
print ("Error")
print ("Please only type book or cancel")
print("There are", b, "people booked on flight", fn)