Saving as csv output of applyin a "main" function in python
<p>I've been applying a main function in Python, by saying:</p>

<pre><code>def main():
    "some code here"

if __name__ == '__main__':
    main()
</code></pre>

<p>Then I get a result like this:</p>

<pre><code>[['This is my car not yours'], ['He answered me sorry'], ['no problem'], ['\nYou are crazy'], ['All cars are the same'], etc...]
</code></pre>

<p>I Want to save the result in a txt and csv file to manipulate it later preserving the same structure: squared parentheses, words, commas, etc.  How can I do that?  Thanks in advance.</p>

<p>Hope this is what you wanted:</p>

<pre><code>def main():
    return [['This is my car not yours'], ['He answered me sorry'], ['no problem'], ['\nYou are crazy'], ['All cars are the same']]

if __name__ == '__main__':
    with open('output.txt', 'w') as f:
        a = ('').join(str(main()))
        f.write(a)
</code></pre>

python csv