The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 305 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Can someone help me add a ValueError check into this finished Python Program? I need it for when the user inputs the plane ticket price and how many bags they're checking out.
Â
I'm not sure if this helps but I was told it should be something like this? Anyway I have attached the program that needs the error checking on.
Â
while True:
   try:
       num1=int(input("Please enter a number:"))
       break
   except ValueError:
   print("Ooops! That was no valid number. Try again...")
Â
   print("your number was",num1)
airport="Please follow the directions and type in your information."
Â
Â
print("Welcome to the Airport Kiosk.")
print("\n\n")
print(airport)
name=input("Please enter your First Name: ")
name2=input("Please enter your Last Name: ")
ticket=float(input("Please enter your plane ticket price: "))
bags=int(input("Please enter the amount of bags you are checking out: "))
Â
if bags >=2:
   print ("\nYour first bag is free. Each additional bag is $25.")
   print ("There will be a charge of $",(bags-1)*25)
   totalprice=(ticket+(bags-1)*25)
   totalprice="%0.2f"%totalprice
   print("\n\nYour final amount will be",totalprice)
Â
if bags <=1:
   print ("\n You will not have to pay a fee according to the amount of bags you entered.")
   ticket="%0.2f"%ticket
   print ("The total price of your flight will be",ticket)
print("Thank you",name,name2)
print("Please enter the payment option below.")
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly