Stuck at More with 'for' - help


#1




just can't figure out what i have done wrong


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


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

print square_list


#2

you need to define square_list above your for each loop like this:

square_list = []

also,

needs to be

square_list.append(i**2)

#3

ohh thanks just understood it a lot more better now.


#4

no problem, glad you got it


#5

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