We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Counting the Items in a List

Remember that we can iterate over all the elements in a list using a loop. For example, the following code will print each item in the sports list.

for i in range(0, len(sports)):
    print(sports[i])

Assignment

Our players need a way to see how many copies of a specific item they have within their inventory!

Let's finish the get_item_counts function.

Tip

The example shows you how to access the values in a list. Combine this with what you know about comparison and assignment operators to complete the assignment.