This Python program demonstrates basic list operations, including adding, inserting, extending, removing, sorting, and finding the index of an element in a list.
- Create an empty list.
- Append multiple elements.
- Insert a value at a specific position.
- Extend the list with another list.
- Remove the last element.
- Sort the list in ascending order.
- Find and display the index of a specific element.
- Start with an empty list
my_list. - Append the values
10, 20, 30, 40. - Insert
15at the second position (index 1). - Extend the list with
[50, 60, 70]. - Remove the last element from the list.
- Sort the list in ascending order.
- Find the index of
30and display it.
Final list: [10, 15, 20, 30, 40, 50, 60]
Index of 30: 3