I often start small automation scripts with a simple list. For example, when I build a local command-line app to track leave requests for a 10-person team, I need a place to collect employee names, requested dates, and approval statuses before saving anything.
That is where knowing how to append to an array in Python becomes useful. Python developers usually use lists as flexible arrays, but you may also work with the built-in array module or a NumPy array in data-heavy projects.
In this guide, I will show you the practical ways to append values, multiple items, records, and NumPy data without creating common bugs.
What Does Append to Array Mean in Python?
An array is an ordered collection of values. In Python, a list is the most common structure people call an array because it stores multiple values in one variable and lets you change it later.
For example, this list stores leave types for a small HR leave management script:
leave_types = ["Sick Leave", "Casual Leave", "Earned Leave"]
print(leave_types)
Output:
['Sick Leave', 'Casual Leave', 'Earned Leave']
I executed the above example code and added the screenshot below.

When you append something, you add it to the end of that collection. You can append a single employee name, a complete leave request record, or values received from user input.
If you are new to Python collections, it also helps to understand the difference between lists, tuples, sets, and dictionaries. Each structure solves a different problem, but lists work best when the order of items matters and you expect changes.
Append to Array in Python With append()
The append() method is the best option when you need to add one item to the end of a Python list. It changes the original list directly.
Here is a basic example:
employees = ["Emily", "Michael", "Sophia"]
employees.append("James")
print(employees)
Output:
['Emily', 'Michael', 'Sophia', 'James']
I executed the above example code and added the screenshot below.

The append() method adds "James" as one new item at the final position. It does not create a new list.
This is useful in a command-line application where users enter one leave request at a time.
leave_requests = []
employee_name = input("Enter employee name: ")
leave_requests.append(employee_name)
print("Current requests:", leave_requests)
If the user enters Emily, Python stores that value in the list:
Current requests: ['Emily']
Use append() when your script receives one value per action. It keeps the code easy to read and works well for beginner Python projects.
You can also explore how to add elements to an empty list in Python when you need more examples with blank lists.
Pro Tip: I have found that
append()is the safest choice for collecting one record at a time. Do not assign its result to another variable becauseappend()returnsNone, not the updated list.
For example, this is incorrect:
employees = ["Emily", "Michael"]
updated_employees = employees.append("Sophia")
print(updated_employees)
Output:
None
I executed the above example code and added the screenshot below.

Write this instead:
employees = ["Emily", "Michael"]
employees.append("Sophia")
print(employees)
Append Multiple Values With extend()
Use extend() when you need to append several values from another iterable. An iterable is an object that Python can loop through, such as a list, tuple, string, or set.
Suppose your leave management script receives a batch of employees from another department:
employees = ["Emily", "Michael"]
new_employees = ["Sophia", "James", "Olivia"]
employees.extend(new_employees)
print(employees)
Output:
['Emily', 'Michael', 'Sophia', 'James', 'Olivia']
The extend() method adds each employee as a separate list item. This differs from append().
employees = ["Emily", "Michael"]
new_employees = ["Sophia", "James"]
employees.append(new_employees)
print(employees)
Output:
['Emily', 'Michael', ['Sophia', 'James']]
Python adds the complete new_employees list as one nested item. That may be correct when you want grouped data, but it is wrong when you expect a flat employee list.
Here is the difference:
| Method | Input | Result |
|---|---|---|
| append() | One item | Adds one item, including a list as a nested list |
| extend() | Multiple values | Adds each value as a separate item |
For batch data, extend() creates cleaner results. You can later flatten a list of lists in Python if nested data already exists.
Append a List to Create Nested Data
Sometimes you actually want a nested list. A nested list is a list that contains one or more lists.
For a leave request app, each leave request might contain an employee name, start date, end date, and approval status.
leave_requests = []
request = ["Emily", "2026-07-20", "2026-07-22", "Pending"]
leave_requests.append(request)
print(leave_requests)
Output:
[['Emily', '2026-07-20', '2026-07-22', 'Pending']]
This approach keeps each leave request together. You can add another request later:
leave_requests.append(
["Michael", "2026-07-25", "2026-07-25", "Approved"]
)
print(leave_requests)
Output:
[
['Emily', '2026-07-20', '2026-07-22', 'Pending'],
['Michael', '2026-07-25', '2026-07-25', 'Approved']
]
You can access the first request with an index:
first_request = leave_requests[0]
print(first_request)
print(first_request[0])
Output:
['Emily', '2026-07-20', '2026-07-22', 'Pending']
Emily
The first index selects the request, and the second index selects a value inside that request. If you work with this layout, learn how to iterate through a 2D array in Python because nested lists behave like a simple two-dimensional array.
Build a Leave Request List Step by Step
Let us build a small real-world example. This local Python script collects leave requests from employees and appends each record to a list.
Create a file named leave_requests.py:
leave-request-app/
│
└── leave_requests.py
This one-file structure works well for a small practice project. Once your app grows, move functions into separate modules for input validation, database work, and reporting.
Start with an empty list:
leave_requests = []
Next, collect values from the user:
employee_name = input("Enter employee name: ")
start_date = input("Enter start date (YYYY-MM-DD): ")
end_date = input("Enter end date (YYYY-MM-DD): ")
leave_type = input("Enter leave type: ")Now combine those values into one record:
request = {
"employee": employee_name,
"start_date": start_date,
"end_date": end_date,
"leave_type": leave_type,
"status": "Pending"
}A dictionary stores data as key-value pairs. It makes the record easier to understand than a list because you access values by names like "employee" and "status".
Append the dictionary to the main list:
leave_requests.append(request)
print("\nLeave request added successfully.")
print(leave_requests)
Here is the complete script:
leave_requests = []
employee_name = input("Enter employee name: ")
start_date = input("Enter start date (YYYY-MM-DD): ")
end_date = input("Enter end date (YYYY-MM-DD): ")
leave_type = input("Enter leave type: ")
request = {
"employee": employee_name,
"start_date": start_date,
"end_date": end_date,
"leave_type": leave_type,
"status": "Pending"
}
leave_requests.append(request)
print("\nLeave request added successfully.")
print(leave_requests)
A sample run looks like this:
Enter employee name: Emily
Enter start date (YYYY-MM-DD): 2026-07-20
Enter end date (YYYY-MM-DD): 2026-07-22
Enter leave type: Casual Leave
Leave request added successfully.
[{'employee': 'Emily', 'start_date': '2026-07-20',
'end_date': '2026-07-22', 'leave_type': 'Casual Leave',
'status': 'Pending'}]
For a growing script, put the append logic inside a reusable function:
def add_leave_request(requests, employee, start_date, end_date, leave_type):
request = {
"employee": employee,
"start_date": start_date,
"end_date": end_date,
"leave_type": leave_type,
"status": "Pending"
}
requests.append(request)
Call the function like this:
leave_requests = []
add_leave_request(
leave_requests,
"Emily",
"2026-07-20",
"2026-07-22",
"Casual Leave"
)
print(leave_requests)
A function groups reusable code under a meaningful name. It helps you avoid repeating the same dictionary and append logic throughout your application. For more practice, see how to define a function in Python.
Validate Data Before You Append
Do not append user input immediately in a real script. Validate it first. Validation checks whether a value meets your rules before your application stores it.
Dates create many avoidable problems. Users may enter 20/07/2026, July 20, or an impossible date such as 2026-02-30. Use the datetime module to confirm the format and calculate leave duration.
from datetime import datetime
def get_valid_date(prompt):
while True:
date_text = input(prompt)
try:
return datetime.strptime(date_text, "%Y-%m-%d").date()
except ValueError:
print("Enter a valid date in YYYY-MM-DD format.")
The datetime.strptime() function converts text into a date object. The try block runs code that may fail, while the except block handles the error without ending the app.
Now use it in the leave request workflow:
from datetime import datetime
leave_requests = []
def get_valid_date(prompt):
while True:
date_text = input(prompt)
try:
return datetime.strptime(date_text, "%Y-%m-%d").date()
except ValueError:
print("Enter a valid date in YYYY-MM-DD format.")
employee_name = input("Enter employee name: ").strip()
start_date = get_valid_date("Enter start date (YYYY-MM-DD): ")
end_date = get_valid_date("Enter end date (YYYY-MM-DD): ")
if end_date < start_date:
print("End date cannot be earlier than start date.")
else:
duration = (end_date - start_date).days + 1
request = {
"employee": employee_name,
"start_date": start_date.isoformat(),
"end_date": end_date.isoformat(),
"days": duration,
"status": "Pending"
}
leave_requests.append(request)
print(f"Request added for {duration} day(s).")
The .strip() method removes accidental spaces from the beginning and end of the employee name. The .isoformat() method converts the date back to the consistent YYYY-MM-DD text format.
You can also read more about how to check if a string is a valid date in Python before building date-based scripts.
Pro Tip: In my experience, always validate values before calling
append(). Removing invalid records later gets difficult when your list feeds reports, files, or a SQLite database.
Append to a Python Array Module
Python also includes an array module. Unlike a list, an array stores values of one data type, such as integers or decimal numbers.
Use it when you need a compact sequence of numeric values and do not need mixed data types.
from array import array
leave_days = array("i", [2, 1, 3])
leave_days.append(5)
print(leave_days)
Output:
array('i', [2, 1, 3, 5])The "i" type code means signed integer values. You cannot append a string to this numeric array.
from array import array
leave_days = array("i", [2, 1, 3])
leave_days.append("five")
Python raises an error because "five" is text, not an integer.
For most business automation scripts, I recommend using lists. Lists are more flexible and easier to work with when you need names, dates, statuses, and other mixed values. Use the array module only when your requirements clearly call for one numeric data type.
Append to a NumPy Array
Use NumPy when you work with large numeric datasets, matrices, scientific calculations, or data analysis. A NumPy array supports fast mathematical operations, but it handles appending differently from Python lists.
First, install NumPy if your project does not have it:
pip install numpy
Then create and append values:
import numpy as np
leave_days = np.array([2, 1, 3])
updated_leave_days = np.append(leave_days, 5)
print(updated_leave_days)
Output:
[2 1 3 5]
The important detail is that np.append() returns a new array. It does not modify the original leave_days variable.
print(leave_days)
Output:
[2 1 3]
You must store the result:
leave_days = np.append(leave_days, 5)
You can append multiple numeric values:
import numpy as np
leave_days = np.array([2, 1, 3])
new_leave_days = np.array([4, 2])
leave_days = np.append(leave_days, new_leave_days)
print(leave_days)
Output:
[2 1 3 4 2]
For multidimensional data, use an axis. Assume each row stores monthly leave totals for one employee.
import numpy as np
monthly_leave_days = np.array([
[1, 2, 0],
[2, 1, 3]
])
new_employee = np.array([[0, 1, 2]])
monthly_leave_days = np.append(
monthly_leave_days,
new_employee,
axis=0
)
print(monthly_leave_days)
Output:
[[1 2 0]
[2 1 3]
[0 1 2]]
The axis=0 argument adds a new row. Both arrays need compatible dimensions. For a broader introduction, review how to work with NumPy arrays in Python.
Avoid repeatedly calling np.append() inside a large loop. NumPy creates a new array every time, which uses extra memory and slows your script. Collect values in a list first, then convert the list to a NumPy array after the loop.
import numpy as np
leave_days = []
for day_count in [2, 1, 3, 5]:
leave_days.append(day_count)
leave_days_array = np.array(leave_days)
print(leave_days_array)
Append With List Concatenation
You can append arrays by combining lists with the + operator.
employees = ["Emily", "Michael"]
new_employees = ["Sophia", "James"]
employees = employees + new_employees
print(employees)
Output:
'Emily', 'Michael', 'Sophia', 'James']
This creates a new list and assigns it to employees. It works, but extend() usually communicates your intention more clearly when you want to add multiple values to an existing list.
Use concatenation when you want to preserve the original list:
current_employees = ["Emily", "Michael"]
new_employees = ["Sophia", "James"]
all_employees = current_employees + new_employees
print(current_employees)
print(all_employees)
Output:
['Emily', 'Michael']
['Emily', 'Michael', 'Sophia', 'James']
You can also use unpacking syntax:
current_employees = ["Emily", "Michael"]
new_employees = ["Sophia", "James"]
all_employees = [*current_employees, *new_employees]
print(all_employees)
This is readable when you combine several lists in one statement. However, for a standard append-to-array task, append() and extend() remain easier for most Python tutorials and maintenance work.
Append Records Before Saving to SQLite
A Python list only keeps data while your script runs. Once you close the command-line application, the list disappears.
For a real HR leave management app, save approved or pending requests in a SQLite database. SQLite is a lightweight database stored in one local file, so it works well for small teams and desktop scripts.
Your project can grow into this structure:
leave-request-app/
│
├── app.py
├── database.py
└── leave_requests.db
Start by creating the database and table:
import sqlite3
connection = sqlite3.connect("leave_requests.db")
cursor = connection.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS leave_requests (
id INTEGER PRIMARY KEY AUTOINCREMENT,
employee TEXT NOT NULL,
start_date TEXT NOT NULL,
end_date TEXT NOT NULL,
days INTEGER NOT NULL,
status TEXT NOT NULL
)
""")
connection.commit()
connection.close()
A database stores data in a structured and persistent form. The CREATE TABLE statement creates a table named leave_requests if it does not already exist.
After validating and appending a request to your in-memory list, insert it into SQLite:
import sqlite3
def save_leave_request(request):
connection = sqlite3.connect("leave_requests.db")
cursor = connection.cursor()
cursor.execute("""
INSERT INTO leave_requests
(employee, start_date, end_date, days, status)
VALUES (?, ?, ?, ?, ?)
""", (
request["employee"],
request["start_date"],
request["end_date"],
request["days"],
request["status"]
))
connection.commit()
connection.close()
The question marks are parameter placeholders. They protect your database query from unsafe input and keep the code easier to maintain.
Use both steps together:
leave_requests.append(request)
save_leave_request(request)
This pattern gives you immediate access to the current list and long-term storage in your SQLite database. It also prepares your project for CRUD operations, which means create, read, update, and delete records.
Things to Keep in Mind
- Choose lists for mixed data: Use a Python list when your array needs names, dates, numbers, and statuses together.
- Use append for one item:
append()adds one object, even if that object is another list. - Use extend for batches:
extend()adds every item from another iterable to the existing list. - Validate before storing: Check names, dates, and numeric values before you append them to prevent bad records.
- Avoid NumPy append loops: Repeated
np.append()calls create new arrays and slow large data-processing tasks. - Save important data: Lists disappear when the script closes, so use SQLite or a file for persistent leave records.
Frequently Asked Questions
How do I append an item to an array in Python?
Use the append() method on a Python list. For example, numbers.append(10) adds 10 to the end of the numbers list. Python lists are the most common array-like structure in Python.
What is the difference between append() and extend() in Python?
append() adds one item to a list, while extend() adds each item from another iterable. If you append a list, Python creates a nested list. If you extend with that list, Python adds its values individually.
Can I append multiple items to a Python list?
Yes, use extend() to append multiple values from another list, tuple, or set. You can also use list concatenation with the + operator when you want a new combined list.
Why does Python append return None?
The append() method changes the existing list in place. Python returns None to show that the method does not create and return a new list. Call append() first, then use the original list variable.
Can I append a dictionary to a Python list?
Yes. Appending dictionaries works very well for structured records, such as employee leave requests. Each dictionary can store named fields like employee name, start date, end date, and approval status.
How do I append to a NumPy array in Python?
Use np.append(array, value) and assign the result back to a variable. NumPy creates a new array instead of changing the original one. For repeated additions, collect values in a Python list first and convert it to NumPy afterward.
You now know how to append to array in Python with lists, the array module, NumPy, and practical leave-request records. For most everyday scripts, use append() for one item and extend() for many items, then validate data before saving it. I hope you found this article helpful.
You May Also Like
- Create arrays in Python
- Initialize an array in Python
- Check the length of an array in Python
- Remove elements from an array in Python
- Convert a list to an array in Python

Bijay Kumar is an experienced Python and AI professional who enjoys helping developers learn modern technologies through practical tutorials and examples. His expertise includes Python development, Machine Learning, Artificial Intelligence, automation, and data analysis using libraries like Pandas, NumPy, TensorFlow, Matplotlib, SciPy, and Scikit-Learn. At PythonGuides.com, he shares in-depth guides designed for both beginners and experienced developers. More about us.