Question: The example program below shows how the above methods might be used to store passenger names and travel destinations in a database. The use of
The example program below shows how the above methods might be used to store passenger names and travel destinations in a database. The use of strip lower and upper standardize userinput for easy comparison.
Run the program below and add some passengers into the database. Add a duplicate passenger name, using different capitalization, and print the list again.
menuprompt Available commands:
add Add passenger
del Delete passenger
print Print passenger list
exit Exit the program
'Enter command:
destinations PHX 'AUS', 'LAS'
destinationprompt Available destinations:
PHX Phoenix
AUS Austin
LAS Las Vegas
'Enter destination:
passengers
printWelcome to Mohawk Airlines!
userinput inputmenupromptstriplower
while userinput 'exit':
if userinput 'add':
name inputEnter passenger name:
stripupper
destination inputdestinationpromptstripupper
if destination not in destinations:
printUnknown destination.
else:
passengersname destination
elif userinput 'del':
name inputEnter passenger name:
stripupper
if name in passengers:
del passengersname
elif userinput 'print':
for passenger in passengers:
printformatpassengertitle passengerspassenger
else:
printUnrecognized command.
userinput inputEnter command:
striplower
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
