9. More with 'for' - CODE HELP


#1




Traceback (most recent call last):
File "python", line 7, in
AttributeError: 'NoneType' object has no attribute 'sort'


Hey Everyone i do not understand how my code is failing. can anyone help out?


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

# Your code here!
for numbers in start_list:
  square_list = square_list.append(numbers ** 2)
  square_list.sort()
  print square_list


#2

The return value of append function is None. That is why you get the error. Just use square_list.append(numbers ** 2) without assignment and the code will work.