More with 'for'


#1



it says:Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: 'int' object has no attribute 'append' 
please help.
my code is:

start_list = [5, 3, 1, 2, 4]
square_list = []
square_list.append(start_list)
  # Your code here!
for square_list in start_list:
 square_list.append(start_list)
 square_list.sort()
print square_list


#2

This is not good practice to name your for loop's instant variable after an already declared variable,

set it to any relevant word like for example,
for number in start_list:

and then remove this line that is outside the for loop,

lastly remember the instructions say to raise all value by the power of 2 so you would append to square list like,

square_list.append(number**2)


#3

wasnt that much off in my code, wanted to square the whole start_list, which works, when i would use numpy-modul like im used too from my computational physics course.

anyway your answer helped me!

thanks a lot!


#4

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