Why my program keeps outputting "None"

Create a function called append_size that has one parameter named my_list.
The function should append the size of my_list (inclusive) to the end of my_list. The function should then return this new list.
For example, if my_list was [23, 42, 108], the function should return [23, 42, 108, 3] because the size of my_list was originally 3.

THIS IS MY CODE:
def append_size(my_list):
length = len(my_list)
new_list = my_list.append(length)
return new_list

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

To preserve code formatting in forum posts, see: [How to] Format code in posts

Your code (with formatting):

def append_size(my_list):
    length = len(my_list)
    new_list = my_list.append(length)
    return new_list

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

The append method modifies a list by appending an item to the end of the existing list.
The original list is modified/mutated but the method itself just returns None. It doesn’t return the modified list. An example may be more useful:

x = [1, 2, 3]
y = x.append(4)
print(y) # None
print(x) # [1, 2, 3, 4]

In your function, you could do:

def append_size(my_list):
    length = len(my_list)
    my_list.append(length)
    return my_list

some_list = [23, 42, 108]
print(append_size(some_list)) # [23, 42, 108, 3]
print(some_list) # [23, 42, 108, 3]

# The function returns the modified list.
# Original list is modified regardless of the absence/presence of return statement.

If you don’t want to modify the original list and want to return a new list, then:

def append_size(my_list):
    length = len(my_list)
    new_list = my_list[:]   # Slicing
    new_list.append(length)
    return new_list

some_list = [23, 42, 108]
print(append_size(some_list)) # [23, 42, 108, 3]
print(some_list) # [23, 42, 108]

# The function returns a new list.
# The original list is not modified.

Slicing or the list type constructor actually create shallow copies. That is good enough for this challenge because the argument is expected to be a list of numbers. However, if there was a list nested within a list, then mutating the nested list in the original list would also mutate the copied list.

lst = [4, 9, [12, 32, 22]]
copied_lst = lst[:]
lst[2][1] = 100
print(lst)  
# Output: [4, 9, [12, 100, 22]]
print(copied_lst) 
# Output: [4, 9, [12, 100, 22]]

For such cases, we can use deepcopy from the copy module after importing (copy — Shallow and deep copy operations — Python 3.11.1 documentation).

However, for this challenge, shallow copying is adequate to accomplish the task.