Appending to a list


I was doing the append_size code challenge for python 3 and had a question as to why this didn’t work.

#Write your function here
def append_size(lst):
length = len(lst)
new_lst = lst.append(length)
return new_lst

#Uncomment the line below when your function is done
print(append_size([23, 42, 108]))

I later skipped the part where i made new_lst = lst.append(length) and simply dropped the new_lst, making it work! I just want to know why if I make a new list it gives the outcome of None.

Thank you!

1 Like


list_name.append(new value)

is acting and changing the list called list_name by adding an additional value to it. From what I recall, you don’t assign a variable to an action(function) like .append(). It’s not returning anything new, it’s simply changing the list_name.

What assignment is this? Having some context might help as well. What is the goal of the challenge?

Please supply a link to the exercise page so we can follow along.

Here is the link to the challenge

OK I understand, but if I were simply assigning a new name for the list, shouldn’t it still print out what the original list was instead of None?

Here is the link to the challenge

1 Like

I see it now. Yes. You were trying to assign a variable to an action. By doing:

new_lst = lst.append(length)

The append() method only modifies the original list. It doesn’t return any value:


you can now call the list_name and get the new list. The list_name is now changed. Because it doesn’t return any value you get none.