title: how do create a linked list in python
body: <p>I am trying to solve a linked list coding challenge in python. And I have given only following class to create a linked list </p>
  
  <pre><code># Definition for singly-linked list.
  class ListNode(object):
      def __init__(self, x):
          self.val = x
          self.next = None
  </code></pre>
  
  <p>I can create a linked list something like this </p>
  
  <pre><code>x = ListNode(1)
  x.next = ListNode(4)
  x.next.next = ListNode(5)
  </code></pre>
  
  <p>however, How do I create iterativly (inside a for loop)</p>