# More with "for": Confused as to what the task is asking me to do

#1

I do not understand what this task is asking of me. Please, can someone clarify this for me.
This is what I have so far:

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

for number in start_list
print square_list``````

I don't believe I fully understand how the "for" function works, and to be honest I didn't understand the previous task using it either and how I got it correct. I would appreciate it if someone could give me an idea as to what it actually does.

#2

Never mind, solved it.

#3

How did you solve it?

#4

I solved it FINALLY! This one was very frustrating.

start_list = [5, 3, 1, 2, 4]
square_list = []
for int in start_list:
print int ** 2
square_list.append(int ** 2)
square_list.sort()

print square_list

#5

this is code
for number in start_list: ## The line ends with a colon (
square_list.append(number**2) ## now we tell that in square list add number **2
square_list.sort() ## sort square list
print square_list

#6

Hi. below is my code:

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

for int in start_list:
print int**2
square_list.append(start_list)
square_list.sort()
print square_list

This code prints the correct numbers but presents them individually on separate lines. I was wondering if there is a command which I can use to collate them back into a list?

#7

Very clean code there my friend. I had it right but used separate commands to accomplish what you did with just one. Bravo!!

#9

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