def len_check(x): x= str(x).strip() if x.isdigit() == True and len(x) <= 8: return False elif len(x) < 8 or len(x) > 12: return False return True
if len_check(abstr) == True: print(abstr)
def len_check(x): x= str(x).strip() if x.isdigit() == True and len(x) <= 8: return False elif len(x) < 8 or len(x) > 12: return False return True
if len_check(abstr) == True: print(abstr)
>>> '123'.isdigit() True >>> '123qwe'.isdigit() False >>> '123qwe'.isalpha() False >>> 'qwe'.isalpha() True >>>
moistНаверное vic57 хотел до вас донести, что методы isdigit() isalpha() и так возвращают True или False.
vic57, простите, не понял, что вы хотели сказать.
moistФункцию нужно было назвать
Здравствуйте. Есть функция
def oil_inside_the_oil(x):
if x.isdigit() and len(x) <= 8:
moist
простите, не понял, что вы хотели сказать.
>>> def f(x): if x.isdigit() and len(x) > 8 : return True elif x.isalpha() and len(x) > 8 and len(x) < 12: return True return False
moistelif замените на if
результат не изменился.
def len_check(x): x= str(x).strip() if x.isdigit() and len(x) <= 8: return False if len(x) < 8 or len(x) > 12: return False return True
moistты неправильно используешь and/or
if len(x) < 8 or len(x) > 12:
>>> 1 > 8 False >>> 1 < 12 True >>> 1 > 8 or 1 < 12 True >>> 1 > 8 and 1 < 12 False >>>
>>> True and False False >>> False and True False
def len_check(x): x= str(x).strip() if x.isdigit() and len(x) <= 8: return False if len(x) < 8: return False if len(x) > 12: return False return True