25 lines
592 B
Python
25 lines
592 B
Python
def duplicates_has(txt: str) -> str:
|
|
seen = ""
|
|
for char in txt:
|
|
if char in seen:
|
|
return char
|
|
seen += char
|
|
return None
|
|
|
|
def main_6ex():
|
|
txt1 = "banana"
|
|
result = duplicates_has(txt1)
|
|
if result:
|
|
print(f'In {txt1} {result} appears more than once')
|
|
else:
|
|
print(f'In {txt1} no character appears more than once')
|
|
|
|
txt2 = "pear"
|
|
result = duplicates_has(txt2)
|
|
if result:
|
|
print(f'In {txt2} {result} appears more than once')
|
|
else:
|
|
print(f'In {txt2} no character appears more than once')
|
|
|
|
main_6ex()
|