cities = ["Boston", "Las Vegas", "Porto Alegre", "Cape Town", "Berlin", "Okinawa", "Sydney"]
hotels = [255, 450, 150, 250, 650, 675, 850]
flights = [950, 3000, 4500, 2750, 2500, 3500, 10500]
def add_destination(city, hotel, flight):
global cities, flights, hotels
print("""Add your desired destination. Please include your hotel and flight cost,
as well as the name of your desired location and hotel.""")
new_place_city = input("Please type your new city: ")
new_place_hotel = int(input("Please type your new hotel's price per night: "))
new_place_flight = int(input("Please type the cost of your flight:"))
cities.append(new_place_city)
hotels.append(new_place_hotel)
flights.append(new_place_flight)
cost = [flights] + [hotels]
def calculate_total_cost(hotels, flights):
global city, hotel, flight, cost
f_cost = sum(flights)
h_cost = sum(hotels)
t_cost = sum({h_cost, f_cost})
result = calculate_total_cost(hotels, flights)
def display_budget_summary(cities, hotels, flights):
for i in range(len(cities)):
print(f"{cities[i]}, ${hotels[i]} ${flights[i]}.")
result = calculate_total_cost(hotels, flights)
print(f"Your current budget/money spent is ${result}.")
while True:
print(f"""Currently, the cities you plan to visit during your vacation are {cities}."
Please choose an option to make any edits to your vacation.""")
print("1. Add a destination")
print("2. View budget summary")
print("3. Exit program")
option = int(input("Please choose an answer: "))
if option == 1:
add_destination(cities, hotels, flights)
elif option == 2:
display_budget_summary(cities, hotels, flights)
elif option == 3:
break
else:
print("Please choose a valid option.")
Выше представлен мой код. Когда я запускаю это в Online Python, я получаю сообщение об ошибке о том, что я достиг максимального расстояния рекурсии, и не понимаю, что я могу исправить. Насколько я понимаю, большинство проблем связано с функцией отображения. Может ли кто-нибудь подробнее объяснить, как я могу исправить эту ошибку?
def add_destination(city, hotel, flight): global cities, flights, hotels print("""Add your desired destination. Please include your hotel and flight cost, as well as the name of your desired location and hotel.""") new_place_city = input("Please type your new city: ") new_place_hotel = int(input("Please type your new hotel's price per night: ")) new_place_flight = int(input("Please type the cost of your flight:")) cities.append(new_place_city) hotels.append(new_place_hotel) flights.append(new_place_flight)
cost = [flights] + [hotels]
def calculate_total_cost(hotels, flights): global city, hotel, flight, cost f_cost = sum(flights) h_cost = sum(hotels) t_cost = sum({h_cost, f_cost}) result = calculate_total_cost(hotels, flights)
def display_budget_summary(cities, hotels, flights): for i in range(len(cities)): print(f"{cities[i]}, ${hotels[i]} ${flights[i]}.") result = calculate_total_cost(hotels, flights) print(f"Your current budget/money spent is ${result}.")
while True: print(f"""Currently, the cities you plan to visit during your vacation are {cities}." Please choose an option to make any edits to your vacation.""") print("1. Add a destination") print("2. View budget summary") print("3. Exit program")
option = int(input("Please choose an answer: "))
if option == 1: add_destination(cities, hotels, flights)
else: print("Please choose a valid option.") [/code] Выше представлен мой код. Когда я запускаю это в Online Python, я получаю сообщение об ошибке о том, что я достиг максимального расстояния рекурсии, и не понимаю, что я могу исправить. Насколько я понимаю, большинство проблем связано с функцией отображения. Может ли кто-нибудь подробнее объяснить, как я могу исправить эту ошибку?
Насколько мне известно, тестирование глубины настроено правильно, однако объекты просто отрисовываются от начала до конца. Я заглянул в графический отладчик и обнаружил, что при рисовании сетки буфер глубины устанавливается в 0 независимо от...
Насколько мне известно, тестирование глубины настроено правильно, однако объекты просто отрисовываются от начала до конца. Я заглянул в графический отладчик и обнаружил, что при рисовании сетки буфер глубины устанавливается в 0 независимо от...
Дана массив A из n положительных чисел. Задача — найти первую точку равновесия в массиве. Точка равновесия в массиве — это такая позиция, в которой сумма элементов перед равна сумме элементов...