Python Lists and Dictionaries// More with 'for'


#1

I am stuck on this section and do not know what to do different. Please help!!

start_list = [5, 3, 1, 2, 4]
square_list = []
start_list.append(x ** 2)

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

print square_list

#2

That line can be removed. Do no alter the start_list.

Did you mean square_list?


#3

I have done what you have said and I get an error message for square_list.append(number ** 2). What am I still doing wrong here??

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


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

print square_list

#4

Your for loop block needs to be indented.


#5

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