Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python making player inventory

#  delcare variable as a list using square brackets []
player_inv = []

#  add item to a list with .append()
player_inv.append("item1", "item2")

# remove an item from list with .remove()
player_inv.remove("item1")

#  check if an item is inside a list
if "item1" in str(player_inv):
	print("Yes it's there")

#  print a whole list horizontally
print(player_inv)
    
#  cycle through each item in an inventory and print out a list one item at a time
x2 = 0
for x in player_inv:
	print(str(x2 + 1) + ". " + str(player_inv[x2]))
    x2 += 1
Comment

PREVIOUS NEXT
Code Example
Python :: ROC plot for h2o package 
Python :: pico 8 pset 
Python :: matplotlib three dimensional plot 
Python :: how to create customer using python api of shopify 
Python :: opencv houghlines only horizontal 
Python :: commanding ip camera(onvif-ptz-control-python) 
Python :: revit dynamo select all categories 
Python :: how to change text in a canvas tkinter 
Python :: python for skip header line 
Python :: orm odoo 
Python :: pyqt line edit mouse position change 
Python :: tkinter call action to py file 
Python :: @action(detail=true) meaning 
Python :: adding the first place value and second value in python 
Python :: correct code to read csv file in python 
Python :: discard method in python 
Python :: run selenium webdriver without opening browser 
Python :: pandas iloc range 
Python :: The simplest way to start using doctest in python 
Python :: checking if something is true. infinite 
Python :: Take input of any number and generate all possible binary strings without recursion 
Python :: Créer un décorateur python 
Python :: Python Tkinter Entry Widget Syntax 
Python :: How to clear out a set in python 
Python :: pygame lerp 
Python :: python async get result 
Python :: how to get total seconds in django queryset for timedelta field 
Python :: enter three numbers and find smallest number in python 
Python :: pandas concatenation (concat) using list comprehension 
Python :: python count down advanced 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =