diff --git a/app/rules.py b/app/rules.py index bd6488d..11c508f 100644 --- a/app/rules.py +++ b/app/rules.py @@ -6,7 +6,8 @@ html = BeautifulSoup(urlopen('https://telegra.ph/pythonchatru-07-07'), 'lxml') def get_rule(li): li = int(li) - try: - return html.find_all('li')[li - 1].text - except IndexError: - return 'Нет такого правила.' + lis = html.find_all('li') + if li <= len(lis): + return lis[li - 1].text + else: + return f'Пока не придумали.'