The following are links to additional questions that our community has asked about this exercise:
This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!
Not seeing your question? It may still have been asked before – try () in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post ().
Hello,
I’m trying to understand if the code I have below will become an issue in a real use scenario as opposed to what the correct solution was – I did not define a new variable in the for loop, i.e. “for number in start_list:”, the output was the same so I am not sure if this is very incorrect by me.
It’s way too soon to be worrying about that. Nothing we do at this stage is going to overburden the system. Concentrate on learning concepts and syntax, and not on the better way to do things. Stick to the lessons and don’t stray much. It’s counterproductive and disruptive.
What is the purpose of square_list = ? Does it define square_list as the numbers in start_list’s brackets? I was wondering how we were able to declare square_list.append a few lines down without any clear declaration of what it was.
First: define a new, empty list, call it square_list
Next: go through the existing list, start_lst
— and, for each element in start_list:
-------- obtain the value of that element, squared
-------- and append that value to square_list
When you are finished, you will have two lists, the original start_list, which is unchanged, and square_list, the list of squares.
In the above logic, the reason for the statement, square_list = [] is to provide a place to store the squared values.
Once again, a great answer. I’m not sure how I glossed by this but it’s so simple when you actually think about the numbers. Perhaps I need to drink some coffee in the morning before asking these questions. So I see why i should write it the original way.
Thanks again for such a good answer for my silly brain.
Even though you removed the statement, because you ran the code with it before you removed it, the variable is still in memory. Refresh the page and try again. It should raise an exception.
I’m in the segment python lists and dictionaries, and i am confused about what to do for the excercise more with ‘for’. I just really dont understand at all what i am supposed to do can someone help me undertand this please becuase i am completely lost and need some guidence on how to do this.
The error you got suggests that square_list was not properly defined. Did you assign square_list to an empty list? And is square_list globally accessible? Posting your code here will help to determine what the exact problem may be.