79529279

Date: 2025-03-23 16:42:57
Score: 1.5
Natty:
Report link

Just do:

n = 3

my_list = ['a', 'b', 'c', 'd', 'e']

del my_list[:n]

print(my_list)

Output:

['d', 'e']

This also works for defining a start index and an end index where you are deleting objects:

start = 1
end = 3

del my_list[start:end]

print(my_list)

Output:

['a', 'd', 'e']
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: user30033510