Number 9


I am stuck at number 9

this is the error message

Traceback (most recent call last):
  File "python", line 9, in <module>
AttributeError: 'int' object has no attribute 'sort'

And this is the code

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

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

for x in square_list:
    print x.sort()


Problem is here:

for x in square_list:
    print x.sort()

This loop is iterating through the list of the numbers, that is why x is a number. In the first iteration x is 25, in second iteration 9, in third iteration 1 etc...

You can't sort the number, but you can sort the whole list:

print square_list