Added task 3
This commit is contained in:
18
basic programming/3rd task/4.py
Normal file
18
basic programming/3rd task/4.py
Normal file
@@ -0,0 +1,18 @@
|
||||
def split(txt: str) -> tuple:
|
||||
space_index = 0
|
||||
while txt[space_index] != ' ':
|
||||
space_index += 1
|
||||
part1 = txt[:space_index]
|
||||
part2 = txt[space_index+1:]
|
||||
return part1, part2
|
||||
|
||||
def main_4ex():
|
||||
txt1 = "Hello World"
|
||||
part1, part2 = split(txt1)
|
||||
print(f'For input {txt1} we get {part1} and {part2}')
|
||||
|
||||
txt2 = "Leo Messi"
|
||||
part1, part2 = split(txt2)
|
||||
print(f'For input {txt2} we get {part1} and {part2}')
|
||||
|
||||
main_4ex()
|
||||
Reference in New Issue
Block a user