11. List Manipulation in Functions


  1. List Manipulation in Functions

    Oops, try again. list_extender([1, 2, 3, 4]) resulted in an error: 'NoneType' object has no attribute 'append'

Replace this line with your code. 
n = [3, 5, 7]
# Add your function here
def list_extender(lst):
    lst = lst.append(9)
    return list_extender(lst)


The append() function doesn't return a new modified list so you can't really store it in a variable. Instead, it adds to the existing list so just


will suffice. Instead of

lst = lst.append(9)

Also, you're calling the function in your return statement. You just need to return your list which is lst.


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