title: Converting a List into ListNode
body: <p>I am answering a question on LeetCode and I am having a hard time understanding how to code LinkedList (or ListNodes) in Python. I understand the concept of a LinkedList but I still can't understand how to convert a list of integers into a LinkedList of the same!</p>
  
  <p>I've already tried reading some information on this stuff online and I see there are some recursive options available, but recursion is v.v.costly and I'm not a huge fan of it. Below is LeetCode's implementation of a LinkedList and my way of converting a list into a LinkedList</p>
  
  <pre class="lang-py prettyprint-override"><code># Definition for singly-linked list.
  # class ListNode(object):
  #     def __init__(self, x):
  #         self.val = x
  #         self.next = None
  
  list1 = [4,5,1,2,0,4]
  head = ListNode(list1[0])
  e = 1
  while e &lt; len(list1):
        print(head)
        head.next = ListNode(list1[e])
        head = head.next
        e+=1
  return head
  </code></pre>