Intermediate-python-3, projects: function-args-the-nile error

def calculate_money_made(**trips): total_money_made = 0 for trip_id, trip in trips.item(): trip_revenue = trip.cost - trip.driver.cost total_money_made += trip_revenue return total_money_made # Test the function by calling test_function(calculate_money_made)

For some reason I am recieveing this error but I do not know why.
Traceback (most recent call last):
File “”, line 43, in
File “/home/ccuser/workspace/function-args-nile/”, line 7, in test_function
File “/home/ccuser/workspace/function-args-nile/”, line 62, in test_money
money = f(UEXODI=trip1, DEFZXIE=trip2)
File “”, line 37, in calculate_money_made
for trip_id, trip in trips.item():
AttributeError: ‘dict’ object has no attribute ‘item’

maybe its a typo:
if trips is a dictionary,
then then it should be trips.items() instead of trips.item()
to get a list of tuples for the key-value pairs

1 Like

Wow! that was precisely it. Thank you so much