fix(curriculum): update examples in lecture-working-with-loops-and-sequences (#64379)

This commit is contained in:
Diem-Trang Pham 2025-12-08 11:32:21 -06:00 committed by GitHub
parent 2fee689ea5
commit ff83419f2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -56,22 +56,22 @@ print(numbers) # [1, 2, 2.5, 3, 4, 5]
The following code will insert the number `2.5` at index `2` in the `numbers` list.
If you want to remove an element from a list, you can use the `remove()` method. Here is an example of using the `remove()` method to remove a duplicate number from a `numbers` list:
If you want to remove an element from a list, you can use the `remove()` method. The `remove()` method takes the value of the element to remove as an argument:
```py
numbers = [1, 2, 3, 4, 5, 5]
numbers.remove(5)
numbers = [10, 20, 30, 40, 50, 50]
numbers.remove(50)
print(numbers) # [1, 2, 3, 4, 5]
print(numbers) # [10, 20, 30, 40, 50]
```
It is important to note that this method will only remove the first occurrence of an item. Not all of them:
```py
numbers = [1, 2, 3, 4, 5, 5, 5]
numbers.remove(5)
numbers = [10, 20, 30, 40, 50, 50, 50]
numbers.remove(50)
print(numbers) # [1, 2, 3, 4, 5, 5]
print(numbers) # [10, 20, 30, 40, 50, 50]
```
To remove an element at a specific index in the list, you can use the `pop()` method like this: