Skip to content

Commit 7e93e0c

Browse files
committed
Update example: Deleting a list while iterating over it
* Corrects the explanation for `del` keyword. Fixes satwikkansal#16
1 parent d4a60ac commit 7e93e0c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ Can you guess why the output is `[2, 4]`?
362362

363363

364364
**Difference between `del`, `remove`, and `pop`:**
365+
* `del var_name` just removes the binding of the `var_name` from the local or global namespace (That's why the `list_1` is unaffected).
365366
* `remove` removes the first matching value, not a specific index, raises `ValueError` if the value is not found.
366-
* `del` removes a specific index (That's why first `list_1` was unaffected), raises `IndexError` if an invalid index is specified.
367367
* `pop` removes element at a specific index and returns it, raises `IndexError` if an invalid index is specified.
368368

369369
**Why the output is `[2, 4]`?**

0 commit comments

Comments
 (0)