Skip to content

Commit 21c0a2e

Browse files
authored
Final QA (#623)
1 parent 6301b57 commit 21c0a2e

File tree

3 files changed

+10
-30
lines changed

3 files changed

+10
-30
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# How to Remove Items From Lists in Python
22

3-
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/).
3+
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/).

how-to-remove-item-from-list-python/books.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
books.remove("The Hobbit")
2020
print(books)
2121

22-
books = ["Dragonsbane", "The Hobbit", "Wonder", "Jaws"]
23-
books.remove("The Two Towers")
24-
print(books)
22+
# books = ["Dragonsbane", "The Hobbit", "Wonder", "Jaws"]
23+
# books.remove("The Two Towers")
24+
# print(books)
2525

2626
books = ["Dragonsbane", "The Hobbit", "Wonder", "Jaws"]
2727
del books[0:3]
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,15 @@
1-
phone_numbers = [
2-
"54123",
3-
"54123",
4-
"54123",
5-
"54456",
6-
"54789",
7-
"54789",
8-
]
1+
phone_numbers = ["54123", "54123", "54456", "54789", "54789", "54123"]
92
for phone_number in phone_numbers[:]:
10-
if phone_numbers.count(phone_number) > 1:
3+
while phone_numbers.count(phone_number) > 1:
114
phone_numbers.remove(phone_number)
125
print(phone_numbers)
136

147

15-
phone_numbers = [
16-
"54123",
17-
"54123",
18-
"54123",
19-
"54456",
20-
"54789",
21-
"54789",
22-
]
8+
phone_numbers = ["54123", "54123", "54456", "54789", "54789", "54123"]
239
phone_numbers = list(dict.fromkeys(phone_numbers))
2410
print(phone_numbers)
2511

26-
phone_numbers = [
27-
"54123",
28-
"54123",
29-
"54123",
30-
"54456",
31-
"54789",
32-
"54789",
33-
]
34-
set(phone_numbers)
12+
13+
phone_numbers = ["54123", "54123", "54456", "54789", "54789", "54123"]
14+
phone_numbers = set(phone_numbers)
3515
print(phone_numbers)

0 commit comments

Comments
 (0)