From df42c3965dc55976ac87100b27ee12bb05589c89 Mon Sep 17 00:00:00 2001 From: jwieczor Date: Fri, 15 Nov 2024 22:55:53 +0100 Subject: [PATCH] second task draft --- TaskA02/task02.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 TaskA02/task02.py diff --git a/TaskA02/task02.py b/TaskA02/task02.py new file mode 100644 index 0000000..e2f8012 --- /dev/null +++ b/TaskA02/task02.py @@ -0,0 +1,15 @@ +def contains_word_hamlet(line): + target = "pies" + line_lower = line.lower() + line_length = len(line_lower) + target_length = len(target) + + for i in range(line_length - target_length + 1): + if line_lower[i:i + target_length] == target: + return True + return False + +with open('/Users/jwieczor/Desktop/djfz-24_25-jezyki-1/TaskA02/simple.in', 'r') as file: + for line in file: + if contains_word_hamlet(line): + print(line, end='')