Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
Modify the list fruits = ["apple", "banana"] to change 'banana' to 'pear'.
Use indexing to access the second item in the list.
How would you change the first item in scores = [98, 85, 75] to a score of 100?
Remember that the first index is 0.
What will fruits[1] = 'grapes' do in the list fruits = ['apple', 'banana', 'mango']?
Think about how indexing works.
True or False: You can modify a list in Python by just assigning a new value to an index.
Remember what it means for a list to be mutable.
Given a list my_numbers = [2, 4, 6, 8, 10], create a new list that doubles each element.
Use list comprehension to achieve this.
How can you modify the list names = ["John", "Jane", "Doe"] to change 'Doe' to 'Smith', and print the updated list?
Locate the index of 'Doe' to make the change.
4 more questions in this section. Enroll free to practise them all.
Enroll free