# 7-922-946-93-88 # 8-922-946-93-88 # +7 923 123 45 67 # 0-111-222-33-44 numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] def validate_phone(phone: str) -> bool: exit_str = "" if phone[0] == "+": return False for s in phone: if s in numbers: exit_str += s if exit_str[0] == "7" or exit_str[0] == "8": if len(exit_str) == 11: return True return False print("89231234567", validate_phone("89231234567")) print("8-923-123-45-67", validate_phone("8-923-123-45-67")) print("+79211234567", validate_phone("+79211234567")) print("123456", validate_phone("123456"))