More with 'for'


#1



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

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

    
print square_list


May I know why 'return' cannot be used?


#2

return can only be used inside a function. It cannot be used in a loop written outside of a function. You have a start, but need to change a couple of lines...

return x**2   # remove this line

square_list.append(x**2)    # be sure to indent this line in the for loop

If the exercise asks for a sorted list, then that line is good, just indent if.