Help Please


I thought my code was producing the desired result...all numbers in start_list squared then sorted. The result I get back is correct but it asks me not to modify start_list. I'm not sure how to move forward. Any help would be appreciated.

start_list = [5, 3, 1, 2, 4]
square_list = []

for start_list in start_list:

print square_list

More with 'for'

Oh, I just noticed I've helped you before :slight_smile:. So, when looping, we need to create a new variable that will iterate through our list.

for new_variable in original_variable:

We dont need to define a variable like this in out loop : new_variable = #whatever
we can just do in in our loop :slight_smile:.


I'm sorry, but I just don't understand. I'm a visual learner. Can you please show me in context how that might look so I can figure this out?


So currently, we're looping through start_list. Where is that? it's the start_list after in. The start_list after for is the one that will loop through start_list = [5, 3, 1, 2, 4].
But this is bad because Codecademy doesn't want us to modify our list (start_list).

What should we do? Use something else like a new iterator to loop through start_list. Exapmle:

for new_iterator in my_list:
     #anything happens here...

new_iterator will hold the same values as start_list, the only difference is: new_iterator is not a list! :slight_smile:

Now... whats next in your code:

Since we don't want to modify our list (like I mentioned) we can use our new variable to square (** 2) and append to square_list.


Thank you for your help! I finally have understanding and closure.


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