Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 834 Bytes

File metadata and controls

26 lines (22 loc) · 834 Bytes

Python List Operations

This Python program demonstrates basic list operations, including adding, inserting, extending, removing, sorting, and finding the index of an element in a list.

Features

  • 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.

How It Works

  1. Start with an empty list my_list.
  2. Append the values 10, 20, 30, 40.
  3. Insert 15 at the second position (index 1).
  4. Extend the list with [50, 60, 70].
  5. Remove the last element from the list.
  6. Sort the list in ascending order.
  7. Find the index of 30 and display it.

Example Output

Final list: [10, 15, 20, 30, 40, 50, 60]
Index of 30: 3