title: 'NoneType' object has no attribute 'element'
body: <p>why in the code below when printing head.element inside the while loop I dont get any error
  but the same code print code outside the loop get me an error?</p>
  <pre><code>class node:
    def __init__(self, element):
          self.element = element
          self.next = None
  
  
  head = None
  
  node1 = node(1)
  node2 = node(2)
  
  head = node1
  node1.next = node2
  
  while head != None:
      print(head.element)
      head = head.next
  
  print(head.element)
  </code></pre>