if request.method == 'POST':
if 'bannedphrase' in request.POST: # Имя кнопки
bannedphraseform = BannedPhraseForm(request.POST, prefix='banned')
if bannedphraseform.is_valid():
bannedphraseform.save()
expectedphraseform = ExpectedPhraseForm(prefix='expected')
elif 'expectedphrase' in request.POST:
expectedphraseform = ExpectedPhraseForm(request.POST, prefix='expected')
if expectedphraseform.is_valid():
expectedphraseform.save()
bannedphraseform = BannedPhraseForm(prefix='banned')
else:
bannedphraseform = BannedPhraseForm(prefix='banned')
expectedphraseform = ExpectedPhraseForm(prefix='expected')
import re
def checking(s: str) -> bool:
return bool(re.match(r'^(.+ )*[a-z]+ [a-z]+ [a-z]+( .+)*', s, flags=re.I))
A = (1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000)
L = ('I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M')
def a2l(x):
r = ''
k = len(A)
while k >= 0:
while x >= A[k]:
r += L[k]
x -= A[k]
k -= 1
return r
нормально ли такое непонимание, или же моя голова не готова к этому? Спасибо.
roman = {1: 'I', 2: 'II', 3: 'III', 4: 'IV', 5: 'V'}
arabic = {'I': 1, 'II': 2, 'III': 3, 'IV': 4, 'V': 5}
class Numbers:
@staticmethod
def to_roman(integer: int)->str:
return roman[integer]
@staticmethod
def to_arabic(string: str)->int:
return arabic[string]
def test():
print(Numbers.to_arabic('V'))
print(Numbers.to_roman(3))
if __name__ == '__main__':
test()
просто хотел узнать, что делали вы, после того как вы закончили основы
const elements = document.getElementsByClassName('test')
for (let i = 0; i < elements.length; i++) {
elements[i].addEventListener('click', () => {
alert(i + ' элемент')
})
}
% Defines the maximum width in percent of the containing block