我一直在想我到底做错了什么,只是不明白。Python说第22行有语法错误,但我不知道它有什么问题。。。请帮忙。这是另一个程序的一部分,但这个程序有问题。在
# Destinations Module
# -------------------
# This module provides information about European destinations and rates
# All rates are in euros
def print_options():
# Print travel options
print("Travel Options")
print("--------------")
print("1. Rome")
print("2. Berlin")
print("3. Vienna")
print("")
def get_choice():
# Get destination choice
while True:
try:
choice = int(input("Where would you like to go? ")
if (choice < 1 or choice > 3):
print("Please select a choice between 1 and 3.")
continue
except ValueError:
print("The value you entered is invalid. Only numerical values are valid.)
else:
return choice
def get_info(choice):
# Use numeric choice to look up destination info
# Rates are listed in euros per day
# Choice 1: Rome at €45/day
if (choice == 1)
return "Rome", 45
# Choice 2: Berlin at €18/day
elif (choice == 2)
return "Berlin", 18
# Choice 3: Vienna, €34/day
elif (choice == 3)
return "Vienna", 34
您的代码中有几个错误。请检查此正确版本和我在代码中的注释:
相关问题 更多 >
编程相关推荐