0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
The length of a List can be calculated using the len()
function.
fruits = ["apple", "banana", "pear"]
length = len(fruits)
# 3
The length of the list is equal to the number of items present. Don't be fooled by the fact that the length is not equal to the index of the last element; in fact, it will always be one greater.
Some of our player's inventories are huge, so looking through the entire list is cumbersome. Let's find an easy way for us to get the index of the last item in their inventory.
Complete the get_last_index
function so that it returns the length of the inventory
list minus 1.
Focus Editor
Alt+Shift+]
Next Tab
Alt+Shift+[
Become a member to Submit
Become a member to Run
Become a member to view solution