缺少1个必需的位置参数错误Python 3.6.2

问题描述 投票:0回答:1

这是我的部分程序的代码。我试图让用户输入以返回公寓类型,押金和租金金额。我已经包含了一些我的其他函数,以及给出错误的函数,用于上下文。我收到错误:TypeError:determineRent()缺少1个必需的位置参数:'furniture'我不确定我错过了什么....感谢您的帮助。

def getType():
    print ("<<<<<Apartment Rental Program>>>>>")
    print("       -----------------------")
    print("      Studio --------> 1")
    print("      One Bedroom ---> 2")
    print("      Two Bedroom ---> 3")
    print("      Exit Program --> 4")
    print()
    global choice
    choice= int(input("Enter the type of apartment you wish to rent (1-3 or 4 to exit the program):"))
    global kind
    if choice== 1:
            kind= 'Studio'
    elif choice== 2:
            kind= 'One-Bedroom'
    elif choice== 3:
            kind= 'Two-Bedroom'
    else:
            print("Thank you for inquiring about our apartments for rent!")
            exit()
    while (choice >4 or choice <1):
        print("Invalid apartment type....must be 1-4!")
        choice= int(input("Enter the type of apartment you wish to rent (1-3 or 4 to exit the program):  "))
    if (choice >=1 and choice <=3):
           furn= input("Do you want the apartment furnished (Y/N)?  ")

    global furniture
    def furniture(furn):
        if furn== 'y':
            furniture= 'Furnished'
        elif furn== 'Y':
            furniture= 'Furnished'
        elif furn== 'n':
            furniture= 'Unfurnished'
        elif furn== 'N':
            furniture= 'Unfurnished'
    return kind, furniture #return to function that called them

#use the apartment type and furniture to determine rent and deposit
def determineRent(kind, furniture):
    global rent
    global deposit
    def deposit(kind):
        if kind == 1:
            deposit= 400
        elif kind == 2:
            deposit= 500
        elif kind == 3:
            deposit= 600
    def rent(furniture):
        if (kind)== 1:
            if furniture== 'Furnished':
                        rent= 750
            elif furniture == 'Unfurnished':
                        rent= 600
        elif (kind) == 2:
            if furniture == 'Furnished':
                        rent= 900
            elif furniture == 'Unfurnished':
                        rent= 750
        elif (kind) == 3:
            if furniture == 'Furnished':
                        rent= 1025
            elif furniture == 'Unfurnished':
                        rent= 925
    return rent, deposit #return to the function that called them

#dislpay the users selections and deposit/rent amount based on selections
def displayRent(kind, furniture, rent, deposit):
    if (choice <=3 or choice >=1):
     print("Description:     ", determineRent(kind),determineRent(furniture))
     print("Deposit:         $",determineRent(deposit))
     print("Rent:            $",determineRent(rent))

main()
arguments
1个回答
1
投票

问题是你的函数determineRent期望两个参数kindfurniture。你需要在调用函数时将它们一起传递,这样determineRent( kind, furniture)而不是单独传递它们。

我建议你在继续前进之前通过这个basic tutorial on functions

© www.soinside.com 2019 - 2024. All rights reserved.