title: Converting a list to a linked list
body: <p>I'm trying to figure out to convert a list to a linked list. 
  I already have a class for the link but I'm trying to figure out how to convert a list to linked list, for example:</p>
  
  <pre><code>def list_to_link(lst):
      """Takes a Python list and returns a Link with the same elements.
  
      &gt;&gt;&gt; link = list_to_link([1, 2, 3])
      &gt;&gt;&gt; print_link(link)
      &lt;1 2 3&gt;
      """
  
  
  class Link:
  
      empty = ()
  
      def __init__(self, first, rest=empty):
          assert rest is Link.empty or isinstance(rest, Link)
          self.first = first
          self.rest = rest
  
  def print_link(link):
      """Print elements of a linked list link."""
  
      &gt;&gt;&gt; link = Link(1, Link(2, Link(3)))
      &gt;&gt;&gt; print_link(link)
      &lt;1 2 3&gt;
      &gt;&gt;&gt; link1 = Link(1, Link(Link(2), Link(3)))
      &gt;&gt;&gt; print_link(link1)
      &lt;1 &lt;2&gt; 3&gt;
      &gt;&gt;&gt; link1 = Link(3, Link(Link(4), Link(5, Link(6))))
      &gt;&gt;&gt; print_link(link1)
      &lt;3 &lt;4&gt; 5 6&gt;
      """
      print('&lt;' +helper(link).rstrip() +'&gt;')
  </code></pre>