Added task 3

This commit is contained in:
2024-12-21 23:50:13 +02:00
parent 94318de22d
commit 82ac1fcf4d
7 changed files with 133 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
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()