【发布时间】:2021-01-22 09:45:15
【问题描述】:
我正在为酒店预订系统创建一个代码,它会出现错误消息
ValueError: int() 以 10 为底的无效文字:
每次我运行它时都会出现此错误消息,但我尝试过的其他方法都没有效果
#this program is a hotel booking system
#this program was created on 18/01/21
def Display_heading_and_set_up_variables():
global Hotel_Name, Price_Per_Night
print("HOTEL BOOKING SYSTEM")
Hotel_Name = str("Hotel_indigo")
Price_Per_Night = float("69.99")
def Get_Number_Of_Nights():
global No_Of_Nights, answer, confirmation
#this part of the program will get the number of nights the person is staying for
answer = False
while answer == False:
No_Of_Nights = input(int("How many nights are you going to stay for:"))
while No_Of_Nights <= 1 >= 21:
print("That is an invalid entry - nights booked must be from 1 to 21")
No_Of_Nights = input(int("How many nights are you going to stay for:"))
confirmation = input(str("Have you chosen the correct number of nights you want to stay for:"))
if confirmation == Y or confirmation == y:
answer = True
def Discount_Calculator():
global No_Of_Nights, Discount_percentage
#this part of the program will work out the discount from the number of nights you stayed for
if No_Of_Nights == 1 ==2:
Discount_percentage = 0
elif No_Of_Nights >= 3 <= 7:
Discount_percentage = 5
elif No_Of_Nights >= 8 <= 14:
Discount_percentage = 10
elif No_Of_Nights >= 15 <= 21:
Discount_percentage = 15
def calculate_and_display_final_booking_details():
#this part of the program will calculate and display your final information on booking
global No_Of_Nights, Discount_percentage, Hotel_Name, Price_Per_Night, Discounted_Price_Per_Night
Discounted_Price_Per_Night = Price_Per_Night / 100 * Discount_percentage + Price_Per_Night
print("you have booked" ,No_Of_Nights, "number of nights")
print("you qualify for a" ,Discount_Percentage, "% discount")
print(" the final cost of your booking is:" ,Discounted_Price_Per_Night,)
#main program
Display_heading_and_set_up_variables()
Get_Number_Of_Nights()
calculate_and_display_final_booking_details()
我该如何解决这个问题?提前致谢
【问题讨论】:
-
异常来自Python,而不是IDE,比如IDLE。
标签: python