Mean-Variance-Standard Deviation Calculator Bug

Hello, I tried to define the calculator code and I am not getting my desired results.


import numpy as np

def calculate(list):
   if len(list)!=9:
     raise ValueError("List must contain nine numbers.") 
       calculations = {"mean":[b],"variance":[c],"standard deviation":[d],"maximum":[e],"minimum":[f],"sum":[g]}

       return calculations

Can I get help with debugging this please and thank you
Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Safari/537.36.

Challenge: Mean-Variance-Standard Deviation Calculator

Link to the challenge:

Hi @tolaniakinola

Welcome to FCC!

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

You need to compare your output to the specified output. First, all your calculations are returned as arrays of tuples of arrays when they should be arrays of arrays. Second, you have misnamed maximum and minimum.

There may be other issues as well, but use the tests and check your output against the expected output to find any others.

For a start: a, b, c… are really bad names for variables.
Then maybe print out the objects you are creating, to see what you are actually doing.
For example, b is supposed to be a list. You create a tuple and place that into a list. Which is still a tuple inside a list.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.