Python Fundamentals screen 12/14 debugging

Screen Link:

My Code:

def extract(data_set, index):
    column = []
    for row in data_set[1:]:
        value = row[index]
    return column

def find_sum(a_list):
    a_sum = 0
    for element in a_list
        a_sum += element
    return a_sum

def find_length(a_list):
    length = 0
    for element in a_list:
        length += 1
    return length

def mean(data_set, index):
    column = extract(data_set, index)
    return find_sm(column) / find_length(column)

avg_price = mean(apps_data, 4)
avg_rating = mean(apps_data, 7)

Traceback (most recent call last):
  File "/tmp/", line 86, in run_code_string
    exec(code, variables)
  File "<string>", line 21
    for element in a_list
SyntaxError: invalid syntax

I am trying to debug this code and I do not understand where it is telling me to go, I think line 21, but then I do not know what needs to be fixed. Any and all help would be greatly appreciated since I love learning to code and hope to make it my career in the future

Hi and welcome to the community!

Debugging can be really fun but it can also be very frustrating at times…particularly if you’re just missing ONE little thing and you can’t seem to spot it…which I think is what’s happening to your right now!

Unfortunately, the error codes you get while using the DQ platform can be a little misleading because of how things work on the backend so line numbers may not “line up” exactly so take the line numbers with a grain of salt. That said, the error messages themselves usually provide some text that will point you in the right direction. In this case, this bit of text is your friend:

 for element in a_list

The little carat symbol is pointing to where the problem is. Unfortunately you have more than one line of code that uses the same syntax: for element in a_list but you can simply cycle through each one using CTRL+F to find them more quickly. Can you see what’s missing? Hint: what is required at the end of line of code that starts with for?

Let me know if this isn’t enough of a hint and we can try something else. Happy hunting!

EDIT_1: While playing around with your code to see what the error message looked like from my end and then fixing it, I ran into another error message. Let me know if you’re able to figure out the “next” error message you get (it’s a lot easier to spot/figure out than this one – it’s just a small typo).

EDIT_2: After fixing the above mentioned errors, I found one last error message was being generated. It’s a good one too…one that you will probably bump into again sometime so I’d like to see if you can figure that one out on your own as well. If not, no worries…we can work on it together! Just let me know if you get stuck.

Thank you for the help!

I got the first two done, and I am trying to understand the third error code. This is the error I get

Traceback (most recent call last):
File “/tmp/”, line 86, in run_code_string
exec(code, variables)
File “”, line 22
SyntaxError: cannot assign to function call

My guess is that there is something wrong with the “def mean” loop, right?

Again still learning, so I appreciate the help and your patience =)

I looked it up and Google, stack overflow, was saying that I am trying to add a value to a function call. I just do not know where I am supposed to fix it

Could you give me another hint for this one? I don’t want you to tell me the answer, but a hint would be nice

Nicely done, congrats on fixing the first two!

I’m little worried about the error you’re describing because it is different than the one I experienced yesterday…

Can you please post the code you’re using to get this “third” error? My best guess (as you mentioned) is that you’re trying to assign a value to a function call rather than the normal assigning the results of a function call to a variable. However, you should not be seeing this type of error in this lesson which leads me to believe you’ve accidentally inserted a new bug somewhere. Something probably looks like this somewhere:

some_function() = 3.14

Maybe you’ve added a pair of () somewhere by accident?

Love this attitude and it’s my preferred teaching method! :sunglasses: