Reputation: 1
Here is my code for part of my program. I am attempting to have users input in order to return an apartment type, deposit, and rent amount. I have included some of my other functions, along with the one giving me the error, for context. I am getting the error: TypeError: determineRent() missing 1 required positional argument: 'furniture' I am unsure of what I am missing....thanks for your help.
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()
Upvotes: 0
Views: 692
Reputation: 1604
The issue is your function determineRent
expects two arguments kind
and furniture
. You need to pass them both together while calling the function, this way determineRent( kind, furniture)
rather than passing each of them individually.
I would suggest you to go through this basic tutorial on functions before moving ahead.
Upvotes: 2