Working on a Python script for a number-heavy forum game I'm planning to run. It crashes, though, and I can't quite figure out why; any help would be appreciated!
### IMPORTS ###
#currently none
### FUNCTIONS ###
def getstats(list):
HPF = int(list[1] * (list[0] + 5))
SPF = int(list[2] * (list[0] + 5))
ATKF = int(list[3] * (list[0] + 5))
DEFF = int(list[4] * (list[0] + 5))
SPAF = int(list[5] * (list[0] + 5))
SPDF = int(list[6] * (list[0] + 5))
SPEF = int(list[7] * (list[0] + 5))
print("HP: " + str(HPF))
print("SP: " + str(SPF))
print("ATK: " + str(ATKF))
print("DEF: " + str(DEFF))
print("SPA: " + str(SPAF))
print("SPD: " + str(SPDF))
print("SPE: " + str(SPEF))
### OTHER DEFINITIONS ###
loop = 1 #this is what makes the loop work
### THE LOOP ###
while loop != 0:
Name = str(input("NAME: "))
info = list(input("LV, HP, SP, ATK, DEF, SPA, SPD, SPE: "))
print()
print(Name)
getstats(list)
print()
Traceback (most recent call last):
File "C:/Users/.../stats-list.py", line 36, in <module>
getstats(list)
File "C:/Users/.../stats-list.py", line 8, in getstats
HPF = int(list[1] * (list[0] + 5))
TypeError: 'type' object is not subscriptable
The old version didn't use a list; instead, you had to type bases in one at a time. That was dumb, so I changed it to accept a list, but I apparently messed it up somehow?
That, or I'm entering the list wrong. I looked it up online, and (if I read correctly) you need to enter integers one at a time, each separated from the last by a single space. Is that correct?