Did CodeAcademy fail with an answer?


The exact lesson I am on is: String Methods, Lesson 5

Link: https://www.codecademy.com/courses/python-beginner-sRXwR/1/1?curriculum_id=4f89dab3d788890003000096#

Code asked to input: On line 1, create a variable named parrot and set it to the string "Norwegian Blue". On line 2, type len(parrot) after the word print, like so: print len(parrot). The output will be the number of letters in "Norwegian Blue"!

What I input: parrot = "Norwegian Blue"
print len(parrot)

What the answer page says: parrot = "Norwegian Blue"
print len(parrot)

Error I am getting: Traceback (most recent call last):
File "python", line 2, in
TypeError: 'str' object is not callable

Anyone have any idea if I have done anything wrong or code academy messed up?7

**Ok, so, I closed the tab and re-opened, resumed the python course and apparently the code worked and I have been allowed to progress to Tip Calculator. I still don't understand why it showed this syntax error and didn't let me progress without a refresh and resume **

EDIT NUMBER 2: Well, I got to the tip calculator, and the site sorta glitched out and went back to the first test which I did again and then it went back to lesson 5, I entered the same thing which didnt work before and it let me progress. Weird...



You may have assigned a str directly to len, overwriting the len function.

Refresh the page and submit your code again. If you still get an error message, post your code in its entirety.

EDITED to add the following explanation ...
Evidently, you fixed it.

While you are working on an exercise, Codecademy caches variables that you create. If you had submitted anything like this ...

len = parrot

... that statement would have changed the meaning of the name, len, to refer to a str instead of to the built in len function. Codecademy would cache that in memory even if you later removed that assignment statement.

To remove such a change from Codecademy's memory cache, and thereby restore the original meaning of the name, len, you would need to refresh the page.


oh thanks this will be beneficial information later on. still doesnt explain why the site went all the way back to the first test for no reason :stuck_out_tongue:


Codecademy maintains a memory cache of objects throughout your editing and submission session for an exercise. This aids Codecademy's testing system. However, that does sometimes create confusion when users make an assignment to a variable, and then either remove the variable or change its name. This applies to Codecademy, but is not typical outside Codecademy, if you run a Python program in script mode.

During a Codecademy exercise session, names that you abandon within your code still persist in the cache, even if you are working on the exercise for several hours. If you suspect that this has happened, save your work first by submitting it, and then refresh the page.