/
sejeenn
/
python_basic
Обзор
Документация
Войти
/
sejeenn
/
python_basic
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Module23/04_registration/main.py
37 строк
1 KB
Eugene Vorontsov
Copy repo python basic
03 фев 2025, 20:23
03 фев 2025, 20:23
a8fce4a
Код
Авторство
О чём код?
def checking_for_errors(register_line): error = '' test_ok = False temp = register_line.split() try: if len(temp) == 3: try: if temp[0].isalpha(): test_ok = True except NameError: error = 'поле имени содержит НЕ только буквы' return error try: if '@' in temp[1] and '.' in temp[1]: test_ok = True except SyntaxError: error = 'Поле емейл НЕ содержит @ и .(точку)' return error try: if temp[2].isdigit(): if 9 < int(temp[2]) <= 99: test_ok = True except ValueError: error = 'Поле возраст НЕ является числом от 10 до 99' return error except IndexError: error = 'НЕ присутствуют все три поля' return error with open('registrations.txt', 'r', encoding='utf8') as registration_file: count = 0 for line in registration_file: register_ok = checking_for_errors(line) if register_ok: count += 1 print(count, ':', line, end='')