Skip to content

Conversation

@TimDorotiuk
Copy link

No description provided.


def res_func(str_1):
"""checking the input string"""
if bool(re.match('^[begin ]{1,2}[writeln() ]+[end]{1,2}$', str_1)):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Регулярний вираз не коректний для даної задачі, потрібно замінити на (^(begin begin)(( begin)( readln()| writeln())( begin){0,1}( end){0,1}( readln()| writeln())( end))*$)

@@ -0,0 +1,19 @@
import re

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Недоречно імпортувати цілу бібліотеку, краще замінити на from re import match

Comment on lines +12 to +14
print('YES')
else:
print('NO')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Краще повертати змінну типу bool , для підвищення універсальності функції.

вираз записується без використання пробільних символів
'''

def res_func(str_1):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для кращої читабельності коду функції варто назвати validator

початковому списку.
'''

list_1 = ['jdsf', 'jkldsf', 174268, 325, True, [], '12', []]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Варто список назвати main_list


list_1 = ['jdsf', 'jkldsf', 174268, 325, True, [], '12', []]

print(list_1.count([])) No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нагромаджування виклику функцій . Для підвищення читабільності варто розбити на кілька змінних .

Дано довільний рядок, що є реченням. Вивести кожне 3 слово в цьому реченні.
"""

text_1 = 'Найбілишим містом України і одночасно столицею країни є Київ'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Назву text_1 варто замінити на line для більшї читабельності коду

"""

text_1 = 'Найбілишим містом України і одночасно столицею країни є Київ'
list_sentence = text_1.split()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не зовсім зрозуміла назва list_sentence, краще замінити на list_word

Comment on lines +6 to +7
num_1 = int(input('Пепрше число: '))
num_2 = int(input('Друге число: '))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Немає перевірки на тип данних, які вводяться з клавіатури, що може призвести до помилки ValueError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants