Python Programming Tutorial | Find duplicates in a string using Counter method | GeeksforGeeks

preview_player
Показать описание

This video is contributed by Afzal Ansari

Please Like, Comment and Share the Video among your friends.

Install our Android App:

If you wish, translate into local language and help us reach millions of other geeks:

Follow us on Facebook:

And Twitter:

Also, Subscribe if you haven't already! :)
Рекомендации по теме
Комментарии
Автор

Hey Afzal. How would I approach a script that checks the chars of each line of a text file and makes a tempral output like for example:


[line x] temptations - t3 e1 m1 p1 i1 o1 n1 s1


Then from the temporal output result it counts if there's any character more than twice (in my example the T appears 3 times) and deletes that line, all lines with max. 2 chars of each would remain.


Your script remembered me sowewhat I used to have ages ago on my old PC, but I lost so many scripts on the way, this was a similar one though.


Can you help me?

entaroadun
Автор

Hello Afzal,
Thank you for the video. WC.keys()[j] gives a TypeError: dict_keys object is not subscriptable. Could you please check

balkrishnapatro
Автор

Try This :
from collections import Counter

def alldups(string):
cdict = Counter(string)
for k, v in cdict.items():
if v > 1:
print(k)

if __name__ == '__main__':
string = 'geeksforgeeks'
alldups(string)

bharatapar
Автор

This is the most uninformative video, no explanation for anything . just reading the code

victorML-lmmu
welcome to shbcf.ru