# Average score.

I have to input the number of students (3). Then three scores for each student (I used the dictionary below). Then print the average score for one of the students. Floats are okay. Example input: 3 Sam 1 2 3 Mark 2 3 4 Josh 4 5 6 Josh Output: 5.00 #Josh's average score. I got the following error message: "d = (a)/3 TypeError: unsupported operand type(s) for /: 'dict' and 'int'" So I need to convert everything to an integer or a string (code and link are below)? Any help greatly appreciated. x = int(input()) a = {input():[int(input()), int(input()), int(input())]} b = {input():[int(input()), int(input()), int(input())]} c = {input():[int(input()), int(input()), int(input())]} d = (a)/3 print(d) https://code.sololearn.com/cN410aMjf0uS/#py

9/20/2019 9:43:14 PM

tristach6055 Answers

New AnswerIn your code a is initially int by the time you are doing d = (a)/3 your 'a' is referring to a dictionary. Divide operation is not supported for dictionary, hence the error.

Thanks everyone (almost there)! The following code worked (thanks to all)! Last step is to make the last line an input. As it is now, it will only print the a value (line 2). How do I add an input? I tried several options but got errors on all of them. It should be possible. Thanks in advance for any help. x = int(input()) a = {input():[int(input()), int(input()), int(input())]} b = {input():[int(input()), int(input()), int(input())]} c = {input():[int(input()), int(input()), int(input())]} print(sum(*a.values())/3) https://code.sololearn.com/cu3z7p4Op3CR/#py