Answer to Question #326152 in Python for Vamsi

Question #326152

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 Output2

b a n


1
Expert's answer
2022-04-11T18:47:38-0400
W = str(input())
result = []
result.append(W[0])

for i in range(1, len(W)):
    k = 0
    for j in range(0, len(result)):
        if W[i] == result[j]:
            k = 1
            break
    if k == 0:
        result.append(W[i])
for i in range(len(result)):
    print(result[i], end='')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS