jfz-2023-s474155/TaskA04/run.py

30 lines
789 B
Python
Raw Permalink Normal View History

2023-10-30 11:59:11 +01:00
def checkDigit(char):
digits=['1','2','3','4','5','6','7','8','9']
for j in range(len(digits)):
if char==digits[j]:
return char
return None
def checkMaxDigitsSub(fileToCheck):
with open(fileToCheck, "r", encoding="utf-8") as sampleCheck:
word = ''
previousChar=''
for row in sampleCheck:
for char in row:
if char == '\n':
if word != '':
print(word)
word = ''
if checkDigit(char):
if not checkDigit(previousChar):
word += ' '
word += char
previousChar = char
file = 'simple.exp'
checkMaxDigitsSub(file)