0

input is: This is An Example

Output: This An Exmpl

li = input("Enter your Sting")
res = ''
for ch in li:
    if ch not in res :
        res = res + ch
        print(res, end=' ')
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
  • Whats the question? how come you can have multiple space chars? space char is repeated several times in the output. – Chris Doyle Apr 20 '20 at 15:48
  • Does this answer your question? [Removing duplicate characters from a string](https://stackoverflow.com/questions/9841303/removing-duplicate-characters-from-a-string) – Tomerikoo Apr 20 '20 at 16:31

2 Answers2

1
li = input("Enter your string")
res = ''
for ch in li.lower():
    if ch not in res:
        res = res + ch
print(res.title(), end='')
BK94
  • 59
  • 1
  • 11
0

I am sure there will be a more elegant way to do this but for now here is a working version which you could refactor or reduce if needed

user_input = input("sentance: ")
seen = set()
filtered_words = []
for word in user_input.split():
    filtered_word = ""
    for char in word:
        if char.lower() in seen:
            continue
        filtered_word += char
        seen.add(char.lower())
    if filtered_word != "":
        filtered_words.append(filtered_word)
print(*filtered_words)
Chris Doyle
  • 10,703
  • 2
  • 23
  • 42