From 7e93e0cb91aca415d3edf172a023d39744fa116c Mon Sep 17 00:00:00 2001 From: Satwik Kansal Date: Tue, 5 Sep 2017 00:05:07 +0530 Subject: [PATCH] Update example: Deleting a list while iterating over it * Corrects the explanation for `del` keyword. Fixes https://github.com/satwikkansal/wtfpython/issues/16 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2674f0d..fe77a3d 100755 --- a/README.md +++ b/README.md @@ -362,8 +362,8 @@ Can you guess why the output is `[2, 4]`? **Difference between `del`, `remove`, and `pop`:** +* `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). * `remove` removes the first matching value, not a specific index, raises `ValueError` if the value is not found. -* `del` removes a specific index (That's why first `list_1` was unaffected), raises `IndexError` if an invalid index is specified. * `pop` removes element at a specific index and returns it, raises `IndexError` if an invalid index is specified. **Why the output is `[2, 4]`?**