0

Enter a input list and delete its any one of element which is coming multiple time

16th Dec 2016, 1:17 PM
Prabhakar Banafar
Prabhakar Banafar - avatar
2 Respostas
+ 1
You could use the 'is' command as shown below: b=[1,1,2,3] if b[1] is b[0]: print ("Yes") del b[1] Probably not the best, but a way to identify if a number repeats.
16th Dec 2016, 1:46 PM
luc_gar
luc_gar - avatar
0
Create a set from the list. Set is a collection of unique objects. ls = [1,2,1,3,4] ls = list(set(ls)) print ls // [1,2,3,4]
16th Dec 2016, 2:23 PM
Rishi Anand
Rishi Anand - avatar