Untitled
unknown
python
2 years ago
1.5 kB
12
Indexable
class Phone(): ALL_CHECKS = False def __init__(self, phone_num): self.phone_num = phone_num Phone.ALL_CHECKS = self.check_plus(phone_num) and Phone.check_plus(phone_num) @classmethod def total_check(cls): return cls.ALL_CHECKS @staticmethod def check_plus(self): if self[0] == "+": return True else: try: if isinstance(int(self[0]), int): if self[0] == "8": return False else: raise Exception except: print("Phone number is not a number :)") @staticmethod def num_validation(self): plus = Phone.check_plus(self) if plus: try: num = int(self[1:]) if len(str(num)) == 11: return True else: return False except: print("Phone number is not a number :)") else: try: num = int(self[1:]) if len(str(num)) == 10: return True else: return False except: print("Phone number is not a number :)") print(Phone.num_validation("89601079685")) print(Phone.num_validation("89601079685123")) ph = Phone("89601079685") print(ph.total_check()) ph2 = Phone("+79601079685") print(ph2.total_check())
Editor is loading...