-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoceans_five_finished.py
More file actions
71 lines (54 loc) · 2.11 KB
/
oceans_five_finished.py
File metadata and controls
71 lines (54 loc) · 2.11 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Ocean's Five Heist Activity
# Creating nested sequences and working with lists.
import random
# create nested sequence with your team; each member's info is a list nested in one big list
theFive = [
["Danny Ocean", "potato", 4, 1],
["Basher Tarr", "banana", 4, 2],
["Linus Caldwell", "taco", 3, 3],
["Reuben Tishkoff", "fish", 2, 4],
["Tess Ocean", "salad", 1, 5]
]
print(theFive)
print()
# loop and test to see if each alias has an "A";
# print a message saying the name of each member with a good alias
# randomly assign a good alias if the alias does not have an A
for agent in theFive:
if "a" in agent[1].lower():
print(agent[0], "has a good alias")
else:
agent[1] = random.choice(("orange", "pasta", "tomato", "beans", "steak"))
print()
print(theFive)
# remove the moles using the del keyword
# del can remove an element from a list by using an index value - del list[index]
# index method - list.index(value) will return a list item's index value
counter = 0
for agent in theFive:
if agent[3] == 3:
mole = theFive.pop(counter)
print("\n" + mole[3], "is a mole and has been removed from the team")
counter += 1
print()
# replace any moles you deleted by concatenating new members
new = [("Isabel Lahiri", "Quesadilla", 3, 1),]
theFive += new
print(new[0][0], "has been added to the team to replace a mole.") # indexing nested elements
print()
print(theFive)
print()
# check to see if your team has one of each specialty
specs = [1, 2, 3, 4, 5] # list of each specialty number
for agent in theFive:
for spec in specs:
if agent[2] == spec:
specs.pop[specs.index(spec)] # remove specialty from specs list if in team
# check strength of team
if len(specs) == 0: # if no specialties left in specs list, then all were found in team
print("Your five have a good mix of specialties.")
elif len(specs) == 1:
print("Your five are missing one specialty.")
else:
print("Your five are missing", len(specs), "specialties")
input("\nPress enter to exit.")