More with for


#1

I've hit a snag with my code below.

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


for number in square_list:
    square_list.append(number**2)# Your code here!
    square_list.sort()

print square_list

I am getting this error:"Oops, try again. square_list should be the same length as start_list". I am not sure what I am doing wrong. Any ideas?


#2

Try to space out number ** 2

like this

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

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

#3

worked for me! :smile:


#4

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