my_list = [1, 2, 3, 4, 5]
del my_list[2] # remove the element at index 2 (value 3)
print(my_list) # [1, 2, 4, 5]
del my_list[1:3] # remove elements at indices 1 and 2 (values 2 and 4)
print(my_list) # [1, 5]
my_list = [1, 2, 3, 4, 5]
my_list.remove(3) # remove the first occurrence of the value 3
print(my_list) # [1, 2, 4, 5]
3.Using the pop() method:
my_list = [1, 2, 3, 4, 5]
value = my_list.pop(2) # remove the element at index 2 (value 3) and get its value
print(value) # 3
print(my_list) # [1, 2, 4, 5]
my_list = [1, 2, 3, 4, 5]
my_list = [x for x in my_list if x != 3] # create a new list without the value 3
print(my_list) # [1, 2, 4, 5]