What's new

Python Pa help python

Yohan12r

Forum Veteran
Elite
Joined
Nov 13, 2021
Posts
1,284
Solutions
141
Reaction
1,798
Points
908

Create a program that will delete all duplicate characters in a string​

Input starts with a number N and is followed by N strings
Output : Print the character with all the duplicate characters removed.

Sample Input #1​

4
Harrenhal
Drogos
Thoros of Myr
Iron Born

Sample Output #1​


enl
Drgs
ThsfMy
IB
 
Last edited:
Here is a Python program that deletes all duplicate characters in a string based on the provided input format:

Python:
def remove_duplicates(input_string):
    result = ""
    for char in input_string:
        if char not in result:
            result += char
    return result

# Input
n = int(input())
for _ in range(n):
    string = input().strip()
    print(remove_duplicates(string))

You can run this program and input the sample input you provided to get the corresponding output. Let me know if you need further assistance or explanation on how the program works.
 

Similar threads

Back
Top