Performing List Operations in Python: Creating, Adding/Removing, Accessing, Sorting, and Reversing Elements
https://www.computerbitsdaily.com/2023/05/performing-list-operations-in-python.html
Write a program to perform the below operations on the list:
- Create a list.
- Add/Remove an item to/from a list.
- Get the number of elements in the list.
- Access elements of the list using the index.
- Sort the list.
- Reverse the list.
ists are one of the most versatile data structures in Python. They can store any type of data, including numbers, strings, and even other lists. Lists are mutable, which means that you can add or remove elements from them as needed. In this blog post, we will cover some of the most common operations that you can perform on a list in Python.

Table of Contents
- Creating a List
- Adding and Removing Elements from a List
- Getting the Number of Elements in a List
- Accessing Elements of a List Using the Index
- Sorting a List
- Reversing a List
| Learn Python with “ Computer Courses — All in One “
1. Creating a List
To create a list in Python, you can simply enclose a comma-separated sequence of values in square brackets. For example:
my_list = [1, 2, 3, 4, 5]
2. Adding and Removing Elements from a List
To add an element to the end of a list, you can use the append() method:
my_list = [1, 2, 3]
my_list.append(4)
print(my_list) # Output: [1, 2, 3, 4]