-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0038_join.py
37 lines (33 loc) · 925 Bytes
/
0038_join.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
menu = [
["egg", "bacon"],
["egg", "sausage", "bacon"],
["egg", "spam"],
["egg", "bacon", "spam"],
["egg", "bacon", "sausage", "spam"],
["spam", "bacon", "sausage", "spam"],
["spam", "sausage", "spam", "bacon", "spam", "tomato", "spam"],
["spam", "egg", "spam", "spam", "bacon", "spam"],
]
# removes all the occurence of spam
for meal in menu:
if meal.count("spam") > 1:
for index in range(len(meal) - 1, -1, -1):
if meal[index] == "spam":
del meal[index]
elif meal.count("spam") == 1:
meal.remove("spam")
print(", ".join(meal))
print('\n'*2)
flowers = [
"Daffodil",
"Evening Primrose",
"Hydrangea",
"Iris",
"Lavender",
"Sunflower",
"Tiger Lily"
]
separator = ", "
# outputs Daffodil | Evening Primrose | Hydrangea | Iris | Lavender | Sunflower | Tiger Lily
output = separator.join(flowers)
print(output)