I have created a piece of coding however I have begun to try to find the average of each persons score, but do not know what else to do. The code does not work:
def average():#makes function 'average'
print ("\nThe Average Score")#outputs the title 'The Average Score'
for pupils in classScore:
pupil["total"] = (int(pupil["Pupil's Score 1"])+int(pupil["Pupil's Score 2"])+int(pupil["Pupil's Score 3"]))
pupil["average"] = (pupil["total"]//3)
print (pupil["Pupil's Name"]+pupil["average"])
average()
The CSV file is laid out like this:
Pupil's Name Pupil's Score 1 Pupil's Score 2 Pupil's Score 3
Joao 10 9 8
Rebecca 7 6 5
Snuffles 0 1 2
The error message that appeared was:
Traceback (most recent call last):
File "E:/Controlled Assesment Computing/Controlled Assesment/Task 3/Try 18.py", line 56, in <module>
average()
File "E:/Controlled Assesment Computing/Controlled Assesment/Task 3/Try 18.py", line 53, in average
print (pupil["Pupil's Name"]+pupil["average"])
TypeError: Can't convert 'int' object to str implicitly
If anyone could help it would be much appreciated.