diff --git a/TaskC02/task2.py b/TaskC02/task2.py index 439bf6f..c66d78e 100644 --- a/TaskC02/task2.py +++ b/TaskC02/task2.py @@ -17,7 +17,9 @@ def check(given_text): # line = line.strip() # print(check(line)) -flag = True -while flag is True: +while True: text = input('Please provide your text: ') - print(check(text)) \ No newline at end of file + if text == 'END': + break + print(check(text)) + print('To end type END') \ No newline at end of file diff --git a/TaskC42/task42.py b/TaskC42/task42.py new file mode 100644 index 0000000..5418dab --- /dev/null +++ b/TaskC42/task42.py @@ -0,0 +1,25 @@ +import re + +pattern = re.compile(r'^N((I[E]{6,})|([O]{6,}))[!]{3,}$') + +def check(given_text): + result = re.search(pattern, given_text) + if result: + return 'yes' + else: + return 'no' + +### test + +# with open('test.in', 'r', encoding='utf-8') as f: +# lines = f.readlines() +# for line in lines: +# line = line.strip() +# print(check(line)) + +while True: + text = input('Please provide your text: ') + if text == 'END': + break + print(check(text)) + print('To end type END')