I think you want:
last_list=[] if p.last_name != None and p.last_name != "": last_list.append(p.last_name) print last_list
Your current if statement:
if p.last_name == None or p.last_name == "": pass
Effectively never does anything. If p.last_name is not a single or empty string, it does nothing inside the loop. If p.last_name is something else, the body of the if statement is skipped.
Also, it looks like your pan_list.append(p.last) is a typo, because I don't see either pan_list or p.last used anywhere in the code you sent.
Joe day
source share