Thanks in advance!
Problems faced:
1) Firstly, i have no idea why all of my if statements are not working.
2)I wanted to run a particular function and after running it i want it to end, but however it continues throughout my entire script.
3) I am not sure if my for loop is used and typed correctly.Hope you guys can correct me(:
Sorry guys, i know its kind of lengthy, hope you guys could take out some time to look at it.
I will appreciate it!
Thanks:)
"""
This is a program about a flight schedule for flights to Paris, Los Angeles,
Dawin
"""
def flight_schedule():
"""
Flight schedule for flights to Paris, Los Angeles, Dawin
"""
# Greet the user
welcome_message()
# Introduce the program to the user and state what it does
intro_message()
# Ask the user to choose a destination
country = choose_destination()
if country is None:
try:
country/0
except:
print "May i know where you intend to go? "
# if a(Paris) is chosen
if country.lower() is "a":
paris_flight_schedule()
# If b(Los_Angeles) is chosen
elif country.lower() is "b":
los_angeles_flight_schedule()
# if both a and b is not chosen
elif country.lower() is "c":
dawin_flight_schedule()
# if neither is selected
if country == None:
return
# FLight schedule of different flights going to Paris
choose_flight_paris = paris_flight_schedule()
# If none of the flights is chosen
choose_flight_paris = raw_input(("Please choose your prefered flights by "
"pressing 1 or 2 "))
if choose_flight_paris is None:
return None
# For loop for Paris flights
available_flights = ["1: Paris via Egypt", "2: Paris Direct"]
chosen_flight = []
for chosen_flight_name in available_flights:
if "1: Paris via Egypt" in chosen_flight_name:
chosen_flight.append(chosen_flight_name)
print chosen_flight_name
# If Flight to Paris via Egypt is chosen
if choose_flight_paris == 1:
flight_paris_via_egypt()
signing_off()
# If Flight to Paris direct is chosen
elif choose_flight_paris == 2:
flight_paris_direct()
signing_off()
# FLight schedule of different flights going to Los Angeles
choose_flight_los_angeles = los_angeles_flight_schedule()
# If None of the flights is chosen
choose_flight_los_angeles = raw_input(("Please choose your prefered flights "
"by pressing 1 or 2 "))
if choose_flight_los_angeles == None:
return None
# If flight to Los Angeles is chosen
if choose_flight_los_angeles == 1:
flight_los_angeles_direct()
signing_off()
# Flight schedule of different flights going to Dawin
choose_flight_dawin = dawin_flight_schedule()
# If None of the flights is chosen
choose_flight_dawin = raw_input(("Please choose your prefered flights "
"by pressing 1 or 2 "))
if choose_flight_dawin == None:
return None
# If flight to Dawin via China
if choose_flight_dawin == 1:
flight_dawin_via_china()
# If flight to Dawin via Canberra
elif choose_flight_dawin == 2:
flight_dawin_via_canberra()
# Signing off
signing_off()
def welcome_message():
print " Welcome to Singapore Changi Airport, "
"departure hall, terminal 3!"
def intro_message():
print " This schedule is to assist you in finding the correct "
"flight departing time and the flight "
"schedules of the other flights flying to the designated countries."
def choose_destination():
country = raw_input(("Please choose a country given below.\n"
" a: Paris\n"
" b: Los Angeles\n"
" c: Dawin\n\n" ))
return ("You have just chosen, "+ country +"")
def paris_flight_schedule():
print ("There are 2 flights going to Paris.\n"
" 1: Via Egypt\n"
" 2: Direct to Paris\n" )
def flight_paris_via_egypt():
print ("The next flight is at 1750hours and "
"arrival time will be the following morning at 1130 hours ")
def flight_paris_direct():
print ("The next flight is at 2300hours and "
"arrival time will be the following morning at 0935hours ")
def los_angeles_flight_schedule():
print ("There are 1 flight going to Los Angeles.\n"
" 1: Direct to Los Angeles\n" )
def flight_los_angeles_direct():
print ("The next flight is at 1130 hours next "
"morning and arrival time will be 1950 hours. ")
def dawin_flight_schedule():
print ("There are 2 flights going to Dawin.\n"
" 1: Via China\n"
" 2: Via Canberra\n" )
def flight_dawin_via_china():
print ("The next flight is at 1600hours and the "
"arrival time will be the following afternoon at 0250hours. ")
def flight_dawin_via_canberra():
print ("The next flight will be the following "
"afternoon 1250hours and the "
"arrival time will be the following afternoon at 2200hours. ")
def signing_off():
print ("Thanks for using the flight schedule program too check out "
" your flights, We sincerely hope that it will be of some use "
" to you.Have a nice day and a pleasant and safe flight.\n\n ")
end_statement = raw_input(("Press Enter to continue checking other "
" flights or type quit to exit "))
if "quit" in end_statement.lower():
return None
else:
flight_schedule()
flight_schedule()

New Topic/Question
Reply




MultiQuote








|