Distinct Characters
Andy has the word W and he wants to print the unique characters in the word in the order of their occurrence.
write a program to help Andy print the unique characters as described above.
NOTE : consider lower and upper case letters as different
INPUT:
The input is a single line containing the word W
OUTPUT:
the output should be a single line containing space separated characters
EXPLANATION:
in the example, the word is MATHEMATICS
The unique characters in the given word are M, A, T, H, E, I, C, S, in the order of occurrence
so the output should be M A T H E I C S
sample input1 : MATHEMATICS
sample output1 : M A T H E I C S
sample input2 : banana
sample output 2 : b a n
string=str(input())
for i in range(0, len(string)):
f=0
for j in range(0, len(string)):
if(string[i]==string[j] and i!=j):
f=1
break
if(f==0):
print(string[i],end="")
Comments
Leave a comment