Read lines from text as a list in Python
<p>I am read data from text file. Every line of my data have the following structure </p>

<pre><code>(110, 'Math', 1, 5)
(110, 'Sports', 1,  5)
(110, 'Geography', 4, 10)
(112, 'History', 1,  9)
....
</code></pre>

<p>and when I am reading the data from the file it is parsed as a string. So for all the lines I parse the data in a list of strings. However I want to create a list of lists with the 4 different elements (intengers and strings). How can I read the file elementwise and not parse it as string?</p>

<p>My code for read the file is the following:</p>

<pre><code>data1 = [line.strip() for line in open("data.txt", 'r')]
</code></pre>

<p>Do as follow :</p>

<pre><code>data1 = [line.strip(')').strip('(').split() for line in open("data.txt", 'r')]
</code></pre>

python