20 lines
418 B
Python
20 lines
418 B
Python
def duplicates_remove(txt: str) -> str:
|
|
seen = ""
|
|
result = ""
|
|
for char in txt:
|
|
if char not in seen:
|
|
result += char
|
|
seen += char
|
|
return result
|
|
|
|
def main_7ex():
|
|
txt1 = "banana"
|
|
print(f'{txt1} {duplicates_remove(txt1)}')
|
|
|
|
txt2 = "apple"
|
|
print(f'{txt2} {duplicates_remove(txt2)}')
|
|
|
|
txt3 = "pear"
|
|
print(f'{txt3} {duplicates_remove(txt3)}')
|
|
|
|
main_7ex() |