Он продолжает говорить, что мои функции ссылаются перед назначением. Кроме того, может ли кто-нибудь сказать мне, правильно ли я вставляю рекурсию
import house def main(): determine_house() determine_phone() determine_car() def determine_house(repeat): house_price=float(input('Enter the price of the house you were going to pay')) num_beds=int(input('Enter the number of bedrooms')) house=house.house(house_price,num_beds) foo=house.get_average_price() woo=house.get_bedrooms() if foo==218000: if woo==2: return ' You are paying average price for your house ' elif woo==1: return ' You are being overpriced for this house relative to bedrooms ' determine_house(repeat-1) else: return ' you are getting a good deal for your house ' elif foo>218000: return ' You are paying too much for a house in general ' else: return ' You are getting a good price for this house in genereal ' def determine_phone(repeat): phone_price=float(input(' Enter the price of the phone you were going to pay ')) type_phone=input(' Enter the type of phone ') phone=phone.house(phone_price,type_phone) voo=phone.get_average_price() coo=phone.get_type_of_phone() if coo==' Android ': if voo==254: return ' you are paying average price ' elif voo>254: return ' you are being overpriced ' determine_phone(repeat-1) else: return ' you are getting a good deal for this phone ' elif coo==' iphone ': if voo==687: return ' you are paying average price for this phone ' elif voo>687: return ' you are being overpiced for this phone ' determine_phone(repeat-1) else: return ' you are getting a good deal for this phone ' else: print('this type of phone is not supported by the engine') def determine_car(repeat): car_price=float(input(' Enter the price of the car you were going to pay ')) model=input('Enter the model of the car youre thinking of buying') car=car.house(car_price,model) boo=car.get_average_price() loo=car.get_model() if loo==' toyota camry ': if boo==23947: return ' you are paying average price for this car ' elif boo>23947: return 'you are being overpriced for this car' determine_car(repeat-1) else: return 'you are getting a good deal for this car' elif loo==' Honda Accord ': if boo==23720: return ' you are paying average price for this car ' elif boo>23720: return ' you are being overpiced for this car ' determine_car(repeat-1) else: return ' you are not getting a good deal for this house ' else: return ' this model of car is not supported by the engine ' main()
Что я уже пробовал:
я пробовал помещать вызовы функций внизу и сверху
line 4, in main determine_house() UnboundLocalError: local variable 'determine_house' referenced before assignment
Patrice T
Дайте точное сообщение об ошибке и положение.
Воспользуйся Улучшить вопрос чтобы обновить ваш вопрос.
James Rich443
линия 4, в основном
determine_house()
UnboundLocalError: локальная переменная 'determine_house', на которую ссылаются перед назначением
James Rich443
теперь он говорит мне об этом
determine_house()
TypeError: determine_house() отсутствует 1 обязательный позиционный аргумент: 'repeat' и его высказывание ожидание блока с отступом, в котором определена каждая функция