More with 'for'


I have this error "Oops, try again. Make sure not to modify start_list!".

My code:

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

for number in start_list: # Your code here!
start_list = number ** 2

print square_list

And the result is True in the Console:

[1, 4, 9, 16, 25]

Where I have modify "start_list"?

Thanks for your help


you modify start_list here:

start_list = number ** 2

you could name this variable things, start_list isn't one of them

yes, the loop will succesfully continue looping, but see what happens when you print start_list after the loop, its modified


I get 16 when I print after the loop :confused:

I do that and it works:

x = number ** 2

My way to code is clean?


which means you modified the list.

i would append number ** 2 directly to the square_lit, but for the rest its clean


Thanks for your advice and your help :slight_smile: