Answer to Question #265554 in Python for GANESH

Question #265554

Given a word W as input, write a program to print the unique character in the word, in the order of their occurrence

Note: consider lower and upper case letters as different


Input

The input is a single line containing as word W

Output:

The out should be a single line containing space- separated character


sample input: MATHEMATICS


sample Output: M A T H E I C S


1
Expert's answer
2021-11-13T23:54:02-0500


SOLUTION TO THE ABOVE QUESTION


SOLUTION CODE


print("INPUT:")
#prompt the user to enter a string
mystring = input("\nEnter a word: ")
#declare a list to store all the characters of the word
my_list = []
#add the characters of the word in the list
for i in mystring:
    my_list.append(i)

#check the characters that appear once in the word and print them
print("\nOUTPUT:\n")
for element in my_list:
    count = 0;
    for i in range(0,len(my_list)):
        if element == my_list[i]:
            count = count+1;
    if count == 1:
        print(element, end=" ")


SAMPLE PROGRAM OUTPUT






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