appending list but error ‘NoneType’ object has no attribute ‘append’

I have a script in which I am extracting value for every user and adding that in a list but I am getting “‘NoneType’ object has no attribute ‘append'”. My code is like

last_list=[]
if p.last_name==None or p.last_name=="": 
    pass
last_list=last_list.append(p.last_name)
print last_list

I want to add last name in list. If its none then dont add it in list . Please help Note:p is the object that I am using to get info from my module which have all first_name ,last_name , age etc…. Please suggest ….Thanks in advance

Leave a Comment