+ 4

input elements into list then pop out duplicate elements into another list without using count function.

in Python. (i used nested for loop but for big list it's not working )

21st Aug 2018, 6:35 PM
Rishabh Mehta
10 Respostas
+ 12
Omar Faruk How would you tell which elements were removed?
2nd Sep 2018, 3:36 PM
Eduardo Petry
Eduardo Petry - avatar
+ 6
Here is my solution based on your description, seems to be working: https://code.sololearn.com/c3BWyxepYW76/?ref=app
21st Aug 2018, 6:53 PM
Eduardo Petry
Eduardo Petry - avatar
+ 6
a = [1, 2, 2, 3, 3, 3, 4] from itertools import groupby z, x = [], [] for q, w in groupby(a): if len(list(w)) > 1: x.append(q) else: z.append(q) print(z, x) ######################### z, x = [], [] [z.append(q) if len(list(w)) == 1 else x.append(q) for q, w in groupby(a)] print(z, x)
21st Aug 2018, 8:08 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 5
Mert Yazıcı How would you tell what are the duplicate elements?
21st Aug 2018, 7:54 PM
Eduardo Petry
Eduardo Petry - avatar
+ 3
thank you and yes its working... 😍
21st Aug 2018, 7:15 PM
Rishabh Mehta
+ 3
with the help of Eduardo's code i made this code..Thank You Eduardo â˜ș https://code.sololearn.com/cqPV0mIR56dn/?ref=app
21st Aug 2018, 7:58 PM
Rishabh Mehta
+ 2
Check Out My Code Simple And Cute https://code.sololearn.com/cqPV0mIR56dn/?ref=app
21st Aug 2018, 7:55 PM
Rishabh Mehta
+ 2
thank you MY.it's working ..i want to print removed elemnts too
21st Aug 2018, 7:56 PM
Rishabh Mehta
+ 2
in 2 line code l=[1,2,3,4,4,3,4,5,7] print(list(set(l)))
2nd Sep 2018, 3:35 PM
Omar Faruk
Omar Faruk - avatar
+ 1
lis=[1,4,2,5,3,6,3,6,4,2] f=set(lis) for i in lis: if i in lis: lis.remove(i) print("remove item:",lis) print("After remove item:",list(f))
2nd Sep 2018, 3:46 PM
Omar Faruk
Omar Faruk - avatar