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

https://www.codecademy.com/courses/learn-intermediate-python-3/projects/function-args-the-nile

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 “script.py”, line 43, in
test_function(calculate_money_made)
File “/home/ccuser/workspace/function-args-nile/test.py”, line 7, in test_function
test_money(fn)
File “/home/ccuser/workspace/function-args-nile/test.py”, line 62, in test_money
money = f(UEXODI=trip1, DEFZXIE=trip2)
File “script.py”, 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