Data Analysis With Python First Project Error HELP Error:TypeError: unsupported operand type(s) for -: ‘dict’ and ‘dict’

Hi,

I’m currently working on my first project to create a function to calculate the mean, variance, std, etc of nine numbers. But I keep getting error unsupported operand type(s) for -: ‘dict’ and ‘dict’.

What can I do to resolve this error?

project link: https://replit.com/@Beejay4L

First, add a print(calculations) right before your return. You’ll see:

{'mean': [[3.0, 4.0, 5.0], [1.0, 4.0, 7.0], 4.0], 'variance': [[6.0, 6.0, 6.0], [0.6666666666666666, 0.6666666666666666, 0.6666666666666666], 6.666666666666667], 'standard deviation': [[2.449489742783178, 2.449489742783178, 2.449489742783178], [0.816496580927726, 0.816496580927726, 0.816496580927726], 2.581988897471611], 'max': [[6, 7, 8], [6, 7, 8], <built-in method tolist of numpy.int64 object at 0x7f4da44900f0>], 'min': [[0, 1, 2], [0, 3, 6], 0], 'sum': [[9, 12, 15], [3, 12, 21], 36]}

Notice how the max part seems different. Fix that and then compare the expected output with your output and you’ll find another error (or just look at your code for the bit that’s different and looks like a copy/paste issue). Fix that and it should pass.

1 Like

Thanks. I saw the error. It’s fixed now.