CBSE Class 12 Computer Science Question 81 of 120

Review of Python Basics — Question 33

Back to all questions
33
Question

Question 28

Write a Python program to remove duplicate characters of a given string.

Solution
input_string = input("Enter the string: ")
unique_chars = {}
for char in input_string:
    if char not in unique_chars:
        unique_chars[char] = True
result = ''.join(unique_chars.keys())
print(result)
Output
Enter the string: hello world
helo wrd
Answer