More with 'for'


Hi Guys, pls help me with the below code.

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

Your code here!

for square_list in start_list:
square_list.append(start_list ** 2)


print square_list

This gives me below error
Traceback (most recent call last):
File “python”, line 6, in
AttributeError: ‘int’ object has no attribute ‘append’

Please let me know what I’m missing here.


AttributeError: ‘int’ object has no attribute ‘append’, what does this mean? We have a integer which doesn’t have an .append() attribute, there is only a single place you use append:

square_list.append(start_list ** 2)

so you are trying to append to square_list, but the error message tells use square_list is of type integer. How come square_list is of type integer?