-
Notifications
You must be signed in to change notification settings - Fork 1
/
Heros inventory.py
55 lines (35 loc) · 1.05 KB
/
Heros inventory.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# tuples
# empty tuple
inventory = ()
# condition tuple
input("\nPress enter to see inventory")
# tuple with items
inventory = ("sword",
"armour",
"shield",
"healing potion")
if not inventory:
print("You are empty handed")
# for each element
print("\nYou are carrying: ")
for item in inventory:
print(item)
print("\nYou have", len(inventory), "items in your possession")
drink = input("\ndrink healing potion? ")
if drink == "yes" or "yep" or "yeah":
print("\nYour health is now replenished")
else:
print("Your health is unaffected")
input("\nPress enter to continue\n")
# concatenate tuples
chest = ("gold", "gems")
print("You find a chest. it contains: ")
print(chest)
print("You add the contents to your inventory")
inventory += chest
input("\nPress enter to see inventory")
print("\nYou are carrying: ")
for item in inventory:
print(item)
print("\nYou have", len(inventory), "items in your possession")
input("\nPress enter to continue")