https://www.codecademy.com/courses/learn-python-3/articles/python-code-challenges-lists
hello i get error from the code under:
lst = [1, 1, 2]
def append_sum(lst) :
lst = (lst.append(lst[-1] + lst[-2]))
lst = (lst.append(lst[-1] + lst[-2]))
lst = (lst.append(lst[-1] + lst[-2]))
return lst
append_sum(lst)
print(lst)
the error is:
Traceback (most recent call last):
File "C:/Users/SONY/Desktop/sal's shipping.py", line 13, in <module>
append_sum(lst)
File "C:/Users/SONY/Desktop/sal's shipping.py", line 7, in append_sum
lst = (lst.append(lst[-1] + lst[-2]))
AttributeError: 'NoneType' object has no attribute 'append'
something should be wrong with data type
and when i put list to make the data type right i get anothe error
code:
lst = [1, 1, 2]
def append_sum(lst) :
lst = list( lst.append(lst[-1] + lst[-2])) )
lst = list( (lst.append(lst[-1] + lst[-2])) )
lst = list( (lst.append(lst[-1] + lst[-2])) )
return lst
append_sum(lst)
print(lst)
error:
File "C:/Users/SONY/Desktop/sal's shipping.py", line 7
lst = list( lst.append(lst[-1] + lst[-2])) )
^
SyntaxError: unmatched ')'