Im having a problem with my code and it says
TypeError: unsupported operand type(s) for +: \'int\' and \'str\'
and i\'m not sur
You can also use map while calculating your score.
print ("here are the scores of",Name1,",well done") # defines scores
print(P1S)
print ("here is the average score of",Name1,",Well Done") # makes average of scores
print(sum(map(int,P1S))/float(len(P1S)))
print ("here are the scores of",Name2,",well done") # defines scores
print(P2S)
print ("here is the average score of",Name2,",Well Done") # makes average of scores
print(sum(map(int,P2S))/float(len(P2S)))
print ("here are the scores of",Name3,",well done") # defines scores
print(P3S)
print ("here is the average score of",Name3,",Well Done") # makes average of scores
print(sum(map(int,P3S))/float(len(P3S)))
Also can you please tell how are you providing the inputs.
Cast the string by default input to an integer so that you can compute average scores:
Score1 = int(input("what did the first person get in their test the first time?"))
You explicitely take care that the things the user inputs are strings:
Score1 = str(input("what did the first person get in their test the first time?"))
if you replace str()
by int()
or float()
(depending on what you expect the input to be), your problem should go away, because you'd get a numeric type rather than a str
ing.