135k views
4 votes
Trying to write a program in python that averages the value of 4 different test scores.

test1 = input("Enter test score 1:")
test2 = input("Enter test score 2:")
test3 = input("Enter test score 3:")
test4 = input("Enter test score 4:")
total = test1 + test2 + test3 + test4
average = total/4
print(average)
close = input("Press any key to close")

For some reason line 5 isn't working. Maybe I need to make the different test variables an integer?

1 Answer

4 votes

Answer:

Yes, you need to put int() around all the inputs, as it will automatically take the input values as strings and thus won't add them as numbers, but stick all the strings together

User PatrickSCLin
by
5.3k points