Added task 3
This commit is contained in:
24
basic programming/3rd task/6.py
Normal file
24
basic programming/3rd task/6.py
Normal 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()
|
||||
Reference in New Issue
Block a user