Python : AttributeError: 'NoneType' object has no attribute 'data'
<p>I am trying to merge 2 sorted linked list into single sorted linked list.</p>

<pre><code>class Node:
    # Function to initialise the node object
    def __init__(self, data):
        self.data =data
        self.next = None

class LinkedList:
       def mergeNode(self, second_list):
        llist4 = LinkedList()
        first_node = self.head
        second_node = second_list.head

        while (first_node!=None or second_node != None):
            if (first_node.data &gt; second_node.data):

                    llist4.push(first_node)
                    prev = first_node
                    first_node = first_node.next

            elif (first_node.data &lt; second_node.data):

                    llist4.push(second_node)
                    prev = second_node
                    second_node = second_node.next

        else:
                llist4.push(first_node)
                llist4.push(second_node)
                prev = second_node
                second_node = second_node.next
                first_node = first_node.next
        return llist4

if __name__ == '__main__':

    llist = LinkedList()
    llist2 = LinkedList()
    llist3 = LinkedList()

    llist.push(15)
    llist.push(10)
    llist.push(5)

    llist2.push(12)
    llist2.push(3)
    llist2.push(2)
        llist3 = llist.mergeNode(llist2)
    llist3.printList()
</code></pre>

<p>But I am getting error as :<br>
<code>" AttributeError: 'NoneType' object has no attribute 'data'"</code><br>
 I am aware that I might be using None value in my code by I am not able to figure out the reason. Someone please help me to find out the problem?</p>