-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0035_nested_lists.py
More file actions
33 lines (28 loc) · 805 Bytes
/
Copy path0035_nested_lists.py
File metadata and controls
33 lines (28 loc) · 805 Bytes
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
empty_list = []
even = [2, 4, 6, 8]
odd = [1, 3, 5, 7, 9]
numbers = [even, odd]
print(numbers)
for number_list in numbers:
print(number_list)
for value in number_list:
print(value)
print()
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"],
# python ignores comma at the end of the last element of the list
["spam", "egg", "spam", "spam", "bacon", "spam"],
]
for meal in menu:
if "spam" not in meal:
print(meal)
for item in meal:
print(item)
else:
print("{0} has a spam score of {1}".format(meal, meal.count("spam")))