I have a CSV file and I read the contents. I need to verify that every element of each row is not empty:
fname = row[0]
if fname is None:
flag = -1
lname = row[1]
if lname is None:
flag = -1
phone = row[2]
if phone is None:
flag = -1
email = row[3]
if email is None:
flag = -1
[...]
Is there a way to optimize this code? Is there a way to do something like this in Python:
fname = row[0] if None else flag = -1 ?
[...]
At the end I will check if flag is -1, I send an error notification (because this is a background task)
if None in (fname, lname, phone, email): flag = -1