How would I make the output of this for loop into a string, into a variable?
<p>In this loop, I'm trying to take user input and continually put it in a list till they write "stop". When the loop is broken, the for loop prints out all of the li's.</p>

<p>How would I take the output of the for loop and make it a string so that I can load it into a variable?</p>

<pre><code>x = ([])
while True:
    item = raw_input('Enter List Text (e.g. &lt;li&gt;&lt;a href="#"&gt;LIST TEXT&lt;/a&gt;&lt;/li&gt;) (Enter "stop" to end loop):\n')
    if item == 'stop':
     print 'Loop Stopped.'
     break   
    else:
     item = make_link(item)
     x.append(item)
     print 'List Item Added\n'


    for i in range(len(x)):
     print '&lt;li&gt;' + x[i] + '&lt;/li&gt;\n'
</code></pre>

<p>I want it to end up like this:</p>

<p>Code:</p>

<pre><code>print list_output
</code></pre>

<p>Output:</p>

<pre><code>&lt;li&gt;Blah&lt;/li&gt;
&lt;li&gt;Blah&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
</code></pre>
