Append method not working

I ran a simple python code on jupyter notebook for just testing the append method
It is not working. It gives none as output.
The code is as given below.

List = [1,2,3,4]
Newlist = List.append(7)
print(Newlist)

Output:-
None

I am new to python so please help me with this code and correct the mistakes if any.

Hello, @Yakul, and welcome to Python Discourse!

Instead of this:

Newlist = List.append(7)

Use this:

List.append(7)
print(List)

By the way, have you learned about aliases versus copies in Python? That is something you should learn about if you intend to copy mutable objects.

For Python’s built-in collections, mutation methods generally return None. This should be in one of the FAQs.

The following pages offer essential information about this forum, including how to format Python code for proper display:

Based on information from the first of those two links, we can format your code for display using backticks by doing this:

```
List = [1,2,3,4]
Newlist = List.append(7)
print(Newlist)
```

When formatted with the above technique, your code would appear as follows in the post:

List = [1,2,3,4]
Newlist = List.append(7)
print(Newlist)

Note that the formatted code is easier to read than the unformatted code that you originally posted. In formatted code, important details, such as any indentation that it might contain, would also be visible.

Let’s consider in detail what your code appears to be intended to do. Please let us know if anything about the following is mistaken.

It seems that you are attempting to create two lists, with the second one being a copy of the first, but with 7 appended to it. So, after we create the first list, we need to copy it to create the second one. There are several techniques available for copying a list, and we will use one of them. After we have a copy of the first list, we can modify it without altering the contents of the first list.

Note that it is conventional among Python programmers to begin the names of variables with lowercase letters.

Below is a revision of your code. Please feel free to ask us any questions that you may have about it.

numbers_a = [1,2,3,4]
numbers_b = numbers_a.copy()
numbers_b.append(7)
print(numbers_a)
print(numbers_b)

Output:

[1, 2, 3, 4]
[1, 2, 3, 4, 7]

I wrote this canonical for the very general concept on Stack Overflow:

Specific to lists, previously existing:

Specific to the append method, many prior duplicates, such as:

Curiously, I can’t find it in the Programming FAQ in the Python documentation. I also was sure it would be there.