More for "for"


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

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

print square_list

why is this not working? what's meant by "return is out of function', a message given by the interpretor?


Return has to be used in a function, you cant use return in a for loop (well, you could if the for loop was in a function). You need a different approach, with the return keyword


Return is ONLY inside functions NOT for loops. Hope that helps!


thanks to both of you kind people!


A post was split to a new topic: More for "for", need help