More of 'for'


I have no idea what todo could I have some assistance please??

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

# Your code here!
for square_list in square_list:
    print square_list


umbers = [5, 3, 1, 2, 4]
numbers_squre = []

for number in numbers:


print numbers_squre


here is the correct code

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

for x in start_list:
    square_list.append(x ** 2)


print square_list

don't forget to examine the differences


for start_list in start_list:
square_list = start_list**2
print square_list
this was my code. i think i understand why you have x. is it because it for the numbers in start_list? Also can you explain you code. I kind of get some of it but not really. Like i thought that you had to do square_list.append() and then = it to x**2. Why have it in the () if nothing in the square_list.sort(). i understand that it just sort the list but then why. Thanks in advance.


Thanks for the excellent answer! This code confuses me because I thought that "x" had to be defined as representing the items in the start_list before it could be used. Does the "for x in the start_list" define "x"?

I did it this way as well as the way you did it and it worked:

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

Your code here!

for x in start_list:
x == start_list
print square_list



Thanks these messages really helped thanks :smile:


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