OVERVIEW
This Python script demonstrates basic list operations such as appending, inserting, extending, removing, sorting, and finding elements in a list.
STEPS PERFORMED
- Create an Empty List
Initializes an empty list named my_list.
- Append Elements
Appends the integers 10, 20, 30, and 40 to my_list.
- Insert an Element
Inserts the integer 15 at the second position (index 1).
- Extend the List
Extends my_list with another list [50, 60, 70].
- Remove the Last Element
Removes the last element in my_list using .pop().
- Sort the List
Sorts my_list in ascending order.
- Find the Index of a Value
Finds and prints the index of the value 30 in my_list.
USAGE
Save the script to a file, e.g., list_operations.py.
Run the script with:
python list_operations.py
The output will display the index of the value 30 after all list operations.
EXPECTED OUTPUT
The index of value 30 is: 3