Answer to Question #282029 in Python for saikalyan reddy

Question #282029

input :- The input is a single line containing the word


output :- The output should be a single line containing space-separated characters


if input 1 is :- MATHEMATICS


then output 1 is :- M A T H E I C S


if input 2 is :- banana


then output 2 is :- b a n


1
Expert's answer
2021-12-23T00:29:37-0500




#Method_One


print("INPUT: ")


#prompting the user to enter a string

my_string = input("\nEnter your required word: ")


#Check the characters in the word and remove duplicates from the given string, then print the output

print("\nOUTPUT: ")

''.join(sorted(set(my_string), key = my_string.index))



# Method_Two

print("INPUT: ")


#prompting the user to enter a string

my_string = input("\nEnter your required word: ")


#declare a list to store all the characters of the word

my_list = ""


for char in my_string:

  if char not in my_list:

    my_list = my_list + char


#Check the characters in the word and remove duplicates from the given string, then print the output

print("\nOUTPUT: ")

print(my_list)


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