Python Learning Series · @onlysamarrr · Day 13 / 30
Day 13 covers list methods. append() adds to the end, insert() adds at a position, remove() deletes by value, pop() takes out the last item, and sort() changes the list itself and returns None.
Phase: Beginner · Reels: 61/450 – 65/450
Day 13 covers list methods. append() adds to the end, insert() adds at a position, remove() deletes by value, pop() takes out the last item, and sort() changes the list itself and returns None.
nums = [10, 20, 30] nums.append(40) nums.insert(0, 5) nums.remove(20) last = nums.pop() print(nums, "popped:", last) nums.extend([1, 2]) print(nums) nums.sort() print(nums) print(list(dict.fromkeys([3, 1, 3, 2])))
[5, 10, 30] popped: 40 [5, 10, 30, 1, 2] [1, 2, 5, 10, 30] [3, 1, 2]
Removing duplicates, sorting scores and managing carts all use these list methods.
Select (tick) an option, then tap Check answer to see instantly whether your answer is right or wrong, with an explanation. You can change your answer and check again.
Q1. What does [1, 2].append([3, 4]) give?
Q2. What does sort() return?
Q3. What does pop() return?
| 61/450 | Concept | append, insert, remove |
| 62/450 | Live demo | pop, sort, reverse demo |
| 63/450 | Common mistake | sort() None return karta |
| 64/450 | Quiz | Quiz: list se duplicates |
| 65/450 | Interview / real life | Interview: append vs extend |