This is what I believe is the relevant part of my code:
def choose_From_Inventory(itemType):
global inventory
string=""
"""sets up how people choose items from inventory"""
for i in range(len(inventory)):
if inventory[i][0]==itemType:
string=string+"["+str(i)+"]: "+inventory[i][4]+"\n"
return string
This returns the error on the if statement.
This happens whenever I call this function:
def pauseScreen():
global hp, inventory, level, location, sq1, sq2, sq3, sq4
"""prints the pause screen, lets them see hp, inventory, and location"""
print("\t\t HP:\n\t\t",hp,"\n\t\tInventory:\n"+str(choose_From_Inventory(0))+"\n"+str(choose_From_Inventory(1))+"\n"+str(choose_From_Inventory(2))+"\n"+str(choose_From_Inventory(3))+"\n\t\tLevel (Location):\n\t\t",level,location)
returnCode=input("Press enter to return or type in quit to quit\n")
if returnCode.lower()=='quit':
quit=input("Are you sure?\n")
if quit.lower()=='yes':
sys.exit()
else:
pauseScreen()
else:
levelCheck()
This doesn't happen every time, but I haven't been able to figure out why it doesn't work. I've tried several other ways to format the if statement, but I was hoping someone would be able to help me here.
Also, I did check several other questions with similar titles, such as this one (TypeError: 'int' object is not subscriptable) and this one (TypeError: 'int' object is not subscriptable in equation) They didn't help me find a solution.
Thanks!
~Wpx
Alright...I was working with a friend, and he found the error. It was in how I was adding an item to the inventory.
Thanks to those who read this, and especially those who tried to find the error.
~Wpx