CBSE Class 12 Computer Science
Question 33 of 57
Review of Python Basics — Question 33
Back to all questions 33
Question Write a Python program to remove duplicate characters of a given string.
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)Enter the string: hello world
helo wrd
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