Predict the Transformation
Carefully trace the operations. What is the final state of the list `items`? Enter the exact Python list representation.
Slice Master
Practice modifying lists using slice assignment and deletion. Define the slice range and the replacement (if any).
Current List:
Remember: Slicing creates powerful ways to modify multiple elements at once!
Debug the Code
Find the potential issue or incorrect outcome in the following Python code snippets involving list modifications.
What is the primary issue or incorrect result?
Scenario Solver
Write Python code to solve these slightly more complex list manipulation tasks. Aim for concise and correct solutions.
Scenario 1: Update Queue
You have a list representing a queue. Add "Task C"
to the end, then remove the item from the *front* (index 0).
Initial list: queue = ["Task A", "Task B"]
Expected result: ["Task B", "Task C"]
Scenario 2: Data Cleanup
Start with the list `data`. Insert the number 0
at index 1. Then, delete the slice containing the last two elements.
Initial list: data = [10, 20, 30, 40]
Expected result: [10, 0, 20]
Scenario 3: Move Element
From the list `items`, remove the element at index 2 using .pop()
, and then insert that *same removed element* back into the list at index 0.
Initial list: items = ['a', 'b', 'c', 'd']
Expected result: ['c', 'a', 'b', 'd']
Module 11 Advanced Practice Complete!
Great job tackling these advanced list modification techniques! You're getting comfortable with Python's list power.
Review the Standard Practice or watch the Video Lesson if needed, or proceed to the next module!