Python Introducing Dictionaries Iterating and Packing with Dictionaries Recap of Iterating and Packing with Dictionaries

Why student.item() is wrong

Hello In this question, why student.item() is wrong

student = {'name': 'Craig', 'major': 'Computer Science', 'credits': 36}

for key, val in student.item():

1 Answer

Steven Parker
Steven Parker
207,989 Points

The method name is "items" (plural).

I still get an wrong answer even with items Steven Parker

student = {'name': 'Craig', 'major': 'Computer Science', 'credits': 36}

for key in student.items(): print(key)