Now that we know how to create new lists, we need to know how to access specific items in the list.
We access items in a list directly by using their index. Indexes start at 0 (the first item) and increment by one with each successive item. The syntax is as follows:
best_languages = ["JavaScript", "Go", "Rust", "Python", "C"]
print(best_languages[1])
# prints "Go", because index 1 was provided
We need to allow our players to access items in their inventories!
Fix our get_leather_scraps
function by changing the value of item_index
to the index in inventory
that holds the value "Leather Scraps".
Focus Editor
Alt+Shift+]
Next Tab
Alt+Shift+[
Become a member to Submit
Become a member to Run
Become a member to view solution