+ 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 )
10 odpowiedzi
+ 12
Omar Faruk How would you tell which elements were removed?
+ 6
Here is my solution based on your description, seems to be working:
https://code.sololearn.com/c3BWyxepYW76/?ref=app
+ 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)
+ 5
Mert Yazıcı How would you tell what are the duplicate elements?
+ 3
thank you and yes its working... 😍
+ 3
with the help of Eduardo's code i made this code..Thank You Eduardo ☺️
https://code.sololearn.com/cqPV0mIR56dn/?ref=app
+ 2
Check Out My Code Simple And Cute
https://code.sololearn.com/cqPV0mIR56dn/?ref=app
+ 2
thank you MY.it's working ..i want to print removed elemnts too
+ 2
in 2 line code
l=[1,2,3,4,4,3,4,5,7]
print(list(set(l)))
+ 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))