Why is my return value not correct?
The instructions ask for the entire list to be
returned, so if you’re only returning a single modified element, that is the issue. Instead, what we want to do is modify the element, and then on the next line write our
return statement that
returns the entire list
x. Like this:
# Modify the single element here
# Return the entire list here
After reading the above answer, I realized my mistake and managed to solve the exercise, but what I don’t understand is why Codecademy was identifying the mistake as a syntax error and the little arrow was pointing towards the = sign? Unless I’m misunderstanding and the little arrow actually points to the whole line of code rather than a particular column.
The syntax error is caught by the Python interpreter, not CC. We cannot write a statement as a return value. The
= sign is not expected there.
My code does. what is in the description, but I got an error message. Why?
Or did I misunderstand something?
I would recommend testing your code with a different list maybe the one that is stated in the error comment. After n create a new list m = [3 , 6] and print (list_functions(m)). You would expect [3,9], but you don’t get that.
Hopefully you’ll be able to identify what is wrong. A hint is it’s in your function list_function.
Thank you, that clarifies it for me.
The “solution” in the interface doesn’t make any sense. The prompt asks specifically for 3 to be added to index , then the result stored in index . When I ran my code, it did exactly what was asked, but for some reason the interface wanted index to be deleted instead of having the novel value stored there. But when I ran the “solution” code, index had been deleted. Is there an error in the interface reading this code improperly?
I just hit the Run button on the same code that the “Solution” button spat out, and the result I initially got popped up: [3, 8, 7]
ya i got the same. mine came out the 3 8 7 (in proper format but it said it was wrong. I have no idea what happened.
My mistake was that in my function i was returning n instead of returning x. The result is exactly the same but I think its not what the test wants so it rejects it. If anyone else is having that issue make sure you return ‘x’ and not return ‘n’ and hopefully it’ll accept it.