Menu Close

Find the duplicate letters in string. Same to do in dictionary way.

Find the duplicate letters in string. Same to do in dictionary way.

from collections import OrderedDict

def remove_duplicate(str1):
  return "".join(OrderedDict.fromkeys(str1))
     

string=input('Enter a String : ')

print(remove_duplicate(string))

Input_1:
Enter a String : fcukthecode
Output:
fcuktheod


Input_2:
Enter a String : programming
Output:
programin


Input_3:
Enter a String : traveller
Output:
travel


ILLUSTRATION OF THE OUTPUT

Executed using terminal(python3)

More Q