-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into python-for-loop
- Loading branch information
Showing
3 changed files
with
10 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# How to Remove Items From Lists in Python | ||
|
||
This folder provides the code examples for the Real Python tutorial [How to Remove Items From Lists in Python](https://realpython.com/how-to-remove-item-from-list-python/). | ||
This folder provides the code examples for the Real Python tutorial [How to Remove Items From Lists in Python](https://realpython.com/remove-item-from-list-python/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,15 @@ | ||
phone_numbers = [ | ||
"54123", | ||
"54123", | ||
"54123", | ||
"54456", | ||
"54789", | ||
"54789", | ||
] | ||
phone_numbers = ["54123", "54123", "54456", "54789", "54789", "54123"] | ||
for phone_number in phone_numbers[:]: | ||
if phone_numbers.count(phone_number) > 1: | ||
while phone_numbers.count(phone_number) > 1: | ||
phone_numbers.remove(phone_number) | ||
print(phone_numbers) | ||
|
||
|
||
phone_numbers = [ | ||
"54123", | ||
"54123", | ||
"54123", | ||
"54456", | ||
"54789", | ||
"54789", | ||
] | ||
phone_numbers = ["54123", "54123", "54456", "54789", "54789", "54123"] | ||
phone_numbers = list(dict.fromkeys(phone_numbers)) | ||
print(phone_numbers) | ||
|
||
phone_numbers = [ | ||
"54123", | ||
"54123", | ||
"54123", | ||
"54456", | ||
"54789", | ||
"54789", | ||
] | ||
set(phone_numbers) | ||
|
||
phone_numbers = ["54123", "54123", "54456", "54789", "54789", "54123"] | ||
phone_numbers = set(phone_numbers) | ||
print(phone_numbers) |