appending list but error 'NoneType' object has no attribute 'append'
list, python
Solution
list is mutable
Change
last_list=last_list.append(p.last_name)
to
last_list.append(p.last_name)
will work
Problem
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