jfz-2023-s464983/TaskA04/run.py
2023-10-29 22:02:40 +01:00

31 lines
1.0 KiB
Python

def findNumber(filename):
substrings = []
with open(filename, 'r', encoding="utf-8") as file:
line = 1
last_number = -1
flag = 0
for line in file:
substring = ''
for i in line:
if i == ' ' or i == '\n':
flag = 0
if i in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']:
if int(i) >= last_number:
if flag == 0:
substring += i
last_number = int(i)
else:
last_number = -1
substring = ''
flag = 1
#break
else:
if len(substring) >= 1:
substrings.append(substring)
substring = ''
last_number = -1
flag = 0
print(substrings)
findNumber('TaskA04/test.txt')