From b213667c174c4c4e39741fae4177ca0bb49dc31c Mon Sep 17 00:00:00 2001 From: jwieczor Date: Fri, 15 Nov 2024 22:52:11 +0100 Subject: [PATCH] first task draft --- TaskA01/task01.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 TaskA01/task01.py diff --git a/TaskA01/task01.py b/TaskA01/task01.py new file mode 100644 index 0000000..072f8cd --- /dev/null +++ b/TaskA01/task01.py @@ -0,0 +1,14 @@ +def contains_word_hamlet(line): + target = "Hamlet" + line_length = len(line) + target_length = len(target) + + for i in range(line_length - target_length + 1): + if line[i:i + target_length] == target: + return True + return False + +with open('/Users/jwieczor/Desktop/djfz-24_25-jezyki-1/TaskA01/simple.in', 'r') as file: + for line in file: + if contains_word_hamlet(line): + print(line, end='')