-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path020.NestedLists.py
More file actions
51 lines (39 loc) · 940 Bytes
/
020.NestedLists.py
File metadata and controls
51 lines (39 loc) · 940 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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 = [
["eggs","bacon"],
["eggs","sausage","bacon"],
["eggs","spam"],
["eggs","spam","bacon"],
["eggs","sausage","spam","bacon"],
["eggs","sausage","spam","bacon","spam","tomato","spam"],
["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 spam core of {1}".format(meal,meal.count("spam")))
print()
for meal in menu:
for item in meal:
if item != "spam":
print(item,end=' ')
print()
print()
for meal in menu:
print(meal)
for index in range(len(meal)-1,-1,-1):
if meal[index]== "spam":
del meal[index]
print("new meal")
print(menu)