This repository is part of an assignment submitted to PowerLearnProject as part of an assignment for Python Module.
This repository contains a Python script demonstrating various list operations. It walks through creating a list, modifying its contents, and performing common tasks like appending, inserting, sorting, and finding elements. The script contains step-by-step comments explaining each operation.
The script includes the following operations:
-
Creating a List
Starts with an empty list. -
Appending Elements
Adds elements10
,20
,30
, and40
to the list. -
Inserting an Element
Inserts the value15
at the second position. -
Extending the List
Merges the list with another list[50, 60, 70]
. -
Removing the Last Element
Uses thepop()
method to remove the last item. -
Sorting the List
Sorts the list in ascending order. -
Finding an Element's Index
Locates the index of the value30
in the sorted list.
-
Clone the repository: git clone https://github.com/aizocraft/PLP-Week2Python-List.git cd PLP-Week2Python-List 2.Run the code python list_operations.py
-
Output It will prints the index of the value 30 in the list It also prints the final sorted list
Index of 30: 3 Final sorted list: [10, 15, 20, 30, 40, 50, 60]
Below is an example of the output generated by the script:
- Python 3
This script is perfect for:
- Beginners learning Python and list operations.
- Developers looking for simple examples of list manipulation.
- Educators seeking examples to teach Python basics.
This project is licensed under the Creative Commons License.
Isaac Kariuki Connect with me on LinkedIn or check out my other repositories!