studentNumber = len(age) - 1
age[studentNumber] = 0
house[studentNumber] = ''
reactionTime[studentNumber] = 0
while True:
try:
age[studentNumber] = int(input("What is the age of the student: "))
except ValueError:
age[studentNumber] = int(input("What is the age of the student: "))
if age[studentNumber] in range(12, 17):
break
house[studentNumber] = input("Which house is the student in (Saturn/Mars): ").lower()
while house[studentNumber] not in {"saturn", "mars"}:
house[studentNumber] = input("Which house is the student in (Saturn/Mars): ").lower()
age.append(0)
house.append('')
reactionTime.append(0)
print(age + " " + house + " " + reactionTime)
I'm trying to validate the input as a string that is "saturn"or "mars", but I'm receiving the error TypeError: can only concatenate list (not "str") to list when I try to add it to my list
The command line:
What would you like to do:
1. Enter new information
2. House-based statsitics
3. Specific Criteria statistics
Enter 1 2 or 3: 1
What is the age of the student: 12
Which house is the student in (Saturn/Mars): saturn
Traceback (most recent call last):
File "python", line 46, in <module>
File "python", line 32, in newInfo
TypeError: can only concatenate list (not "str") to list
age,houseandreactionTimeall lists? In the updated code you have posted they are undefined.age + " " + house + " " + reactionTimeis supposed to beage[studentNumber] + " " + house[studentNumber] + " " + reactionTime[studentNumber]?