Instagram
youtube
Facebook
Twitter

Python Program to Perform Left Rotation of List Elements by Two Positions

   A Python Program to Perform Left Rotation of List Elements by Two Positions
  Code Description:
  This program performs a left rotation of the list elements by two positions, shifting each        element to the left and moving the first two elements to the end of the list.
  Explanation (Dot Points):

my_list is the original list.
my_list[2:] slices the list from index 2 to the end → [30, 40, 50, 60]
my_list[:2] slices the first two elements → [10, 20]
• Concatenating both parts gives the rotated list: [30, 40, 50, 60, 10, 20]
• The result is printed after rotation.

Program:

my_list = [10, 20, 30, 40, 50, 60]

rotated_list = my_list[2:] + my_list[:2]

print("Original List:", my_list)

print("List after left rotation by 2 positions:", rotated_list)