List manipulation in functions - Answer not being accepted


It asks to append 9 to the list by calling the list_extender method. Even though 9 is getting appended to the list in the correct way, it still throws the error of not returning the list. I also tried storing the result in the 'lst' and then return lst separately. That too did not work.

As per the code written:

9 should be appended to the list

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

print list_extender(n)

Instead i get the mentioned error: Oops, try again. list_extender([1, 2, 3, 4]) returned None, did you remember to return the result?


HI you should first append() 9 then return lst like that

    retrun lst

print list_extender(n)


Thanks alot. But why couldn't we return the list directly when we can return the other data types directly?


Have you tried a refresh Browser
as your code seems to be Ok.

++++ reset of session *****************
As you are manipulating with objects
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser


Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).
CTRL 0 to reset browser zoom


that question has been answer here

HOpe that could help you


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