I'm adding each line from a file to a list and everything is working fine up until I check to see that the line contains "@" and ":" if "@" and ":" in line:
. Logically it should work but it seems to be checking the only first item which is "@". If i put ":" first then it only check that rather than both.
email_list = []
with open(f"{file_path}/test.txt", "r") as file:
for line in file:
line = line.replace(' ', '')
if not any(x in line for x in remove_emails):
line = line.strip()
if "@" and ":" in line: #This line is not working
email_list.append(line)
Expected outcome:
if file contains:
user_1@domain:123
user_2@domain
user_3domain:123
Only user_1@domain:123 should be added to the list as it has both @ and :