improve rules

This commit is contained in:
Rykov7
2023-01-23 17:58:12 +03:00
parent 0a8263e2e4
commit 32b63b3510
+5 -4
View File
@@ -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'Пока не придумали.'