find second occurence
Title
Question
list=[2,3,2,4,5,6]
how to delete second occurrence of any number in list
Python-3.4.3 Getting-started-with-Lists 00-01 min 0-10 sec
Answers:
You can use the following code;
num = 2
occur = 0
for ix, elem in enumerate(list1):
if elem == num:
if occur == 0:
occur += 1
else:
list1.pop(ix)
Login to add comment