I was solving a coding problem on Codefights and I ALMOST solved it but, a problem in my code occured and I can't find a way to solve the problem.
my_list = [1, 2, 3, 4, 3, 6]
print(my_list.index(3))
Output : 2
print(my_list[4])
Output : 3
But, here's the problem, when I try to remove the 3 which lies on index 4, Python removes the 3 on the 2nd index, and I don't want this to happen.
For example:
my_list.remove(my_list[4])
print(my_list)
Output : [1, 2, 4, 3, 6]
I want to get the output as : [1, 2, 3, 4, 6]
This is not my actual code, but just an example. Please help me out if you can.