Reputation: 3
I'm getting input information from the user. There are repeated entries. When I find these repeated words, I have to remove this word from the list.
For example, our inputs are: "a, b, c, b, e, a".
I need to get the output to be "c, e".
What function should I write for this?
def essizkelime():
import pandas as pd
a = int(input("Kaç kelime gireceksiniz?"))
i = 1
l = []
while i <= a:
if i == 1:
b = input(print("Kelimeleri giriniz:","\n"))
l.append(b)
else:
b = input()
l.append(b)
#print(str(i) + ". Kelimeniz:" + str(b),"\n")
i += 1
tekliler = set(l)
print(tekliler)
print("Eşsiz Kelimeler: " + str(tekliler))
essizkelime()
Upvotes: 0
Views: 39
Reputation: 26139
l = 'a, b, c, b, e, a'.split(', ')
from collections import Counter
print([l for l,c in Counter(l).items() if c==1])
outputs
['c', 'e']
Upvotes: 1