🐍 Python Pa help python

Yohan12r

Forum Guru

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
 
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.
 

About this Thread

  • 1
    Replies
  • 325
    Views
  • 1
    Participants
Last reply from:
Unknown user

Trending Topics

Online now

Members online
1,080
Guests online
980
Total visitors
2,060

Forum statistics

Threads
2,274,414
Posts
28,955,692
Members
1,234,215
Latest member
Raul ul
Back
Top