Upload files to "TaskA02"

This commit is contained in:
Stanislav Lytvynenko 2025-02-03 00:35:33 +01:00
parent b8cbfda8b5
commit 053e4d3c36

33
TaskA02/run.py Normal file
View File

@ -0,0 +1,33 @@
import os
def TaskA02(file_path):
print("_______")
with open(file_path, 'r',encoding='utf-8') as file:
line_number = 0
for line in file:
line_number += 1
words = []
current_word = ''
for char in line:
if char.isalnum():
current_word += char
elif current_word:
words.append(current_word)
current_word = ''
if current_word:
words.append(current_word)
for i, char in enumerate(words):
updated_chars = []
for ch in char:
if ord(ch)>=65 and ord(ch)<=90:
updated_chars.append(chr(ord(ch) + 32))
else:
updated_chars.append(ch)
words[i] = ''.join(updated_chars)
if "pies" in words:
print(f"Line {line_number}: {line}")
script_dir = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(script_dir, 'simple.in')
TaskA02(file_path)