python making player inventory

Solutions on MaxInterview for python making player inventory by the best coders in the world

showing results for - "python making player inventory"
Emanuele
08 Jan 2019
1#  delcare variable as a list using square brackets []
2player_inv = []
3
4#  add item to a list with .append()
5player_inv.append("item1", "item2")
6
7# remove an item from list with .remove()
8player_inv.remove("item1")
9
10#  check if an item is inside a list
11if "item1" in str(player_inv):
12	print("Yes it's there")
13
14#  print a whole list horizontally
15print(player_inv)
16    
17#  cycle through each item in an inventory and print out a list one item at a time
18x2 = 0
19for x in player_inv:
20	print(str(x2 + 1) + ". " + str(player_inv[x2]))
21    x2 += 1