Lists · practice
Replace List Items
Reading an item does not change a
The item at index 1 changes from "call Sam" to "email Sam". The other two items stay where they are.
This is an important difference from
The index selects the slot
Consider this schedule:
Index 2 selects the third item, so the final list ends with "cycle".
Run the next example and watch the list before and after the
The name scores still refers to the same list. Only one item inside it changes.
What does this code print?
moods = ["calm", "tired", "curious"]
moods[1] = "rested"
print(moods)In the exercise, update the second task and leave the rest of the list untouched.
Task
The task "call Sam" has changed. Replace the second item in tasks with "email Sam", then print the complete
Do not create a second list. Change the existing list by assigning to its
Once it works, press Step in the editor toolbar and watch the list in the