forked from arvimal/100DaysofCode-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_inventory-1.py
More file actions
57 lines (50 loc) · 1.06 KB
/
game_inventory-1.py
File metadata and controls
57 lines (50 loc) · 1.06 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
#!/usr/bin/env python3
def displayInventory(gamers_inventory):
"""
Display the gamer's inventory as:
---
Inventory:
12 arrow
42 gold coin
1 rope
6 torch
1 dagger
Total number of items: 63
---
"""
print("\nInventory of *{}*".format(gamers_inventory["name"]))
count = 0
for key, value in gamers_inventory.items():
if key is "name":
pass
else:
print("{:>15}: {}".format(key, value))
count += value
print("{:>15}: {}".format("Total items", count))
Gamer_1 = {"name": "Gamer_1", "Arrow": 10, "Coins": 40, "Rope": 1, "Torch": 2}
Gamer_2 = {
"name": "Gamer_2",
"Arrow": 8,
"Coins": 20,
"Rope": 1,
"Torch": 2,
"Armor": 50,
}
Gamer_3 = {
"name": "Gamer_3",
"Arrow": 20,
"Coins": 50,
"Rope": 2,
"Torch": 2,
"Armor": 150,
}
Gamer_4 = {
"name": "Gamer_4",
"Arrow": 28,
"Coins": 20,
"Rope": 1,
"Torch": 12,
"Armor": 250,
}
for name in [Gamer_1, Gamer_2, Gamer_3, Gamer_4]:
displayInventory(name)