Вводится список email-адресов в одну строчку через пробел. Среди них нужно оставить только корректно записанные адреса. Будем полагать, что к таким относятся те, что используют латинские буквы, цифры и символ подчеркивания. А также в адресе должен быть символ "@", а после него символ точки "." (между ними, конечно же, могут быть и другие символы). Результат отобразить в виде строки email-адресов, записанных через пробел. Code: Sample Input: [email protected] [email protected] [email protected] [email protected] [email protected] Sample Output: [email protected] [email protected] [email protected] Code: from string import ascii_letters as al, digits as ds symbols = al + ds + '_' print(*filter(lambda x: '@.' < x > symbols, input().split())) Code: # мой вывод почему то пропускает 1 емаил неправильный Test input: [email protected] [email protected] [email protected] [email protected] [email protected] Test output: [email protected] [email protected] [email protected]
Решил Code: import re emails = input().split() res = filter(lambda x: re.findall(r'^[\w][email protected][\w]+.[\w]', x), emails) print(*res)