How do I turn a string of numbers into a list on Python?
<p>I'm trying to figure out how many numbers in a text file are larger than 0.1.
The text file has 1001 last names and numbers in the following format:</p>

<pre><code>Doe 5
Anderson 0.3
Smith 6
</code></pre>

<p>I figured out how to separate the numbers but i'm having trouble converting my string of numbers into a list so that I can then compare them to 0.1</p>

<p>Here is what I have so far:</p>

<pre><code>    infile = open('last.txt')
    lines = infile.readlines()
    for line in lines:
        items = line.split()
        nums = (items[1])
</code></pre>

<p>also, once I have my list, how do I go about comparing it to 0.1?</p>

<p>From your description, and code snippet, you seem to have a file that has a space separated name an number like so:</p>

<pre><code>Name1 0.5
Name2 7
Name3 11
</code></pre>

<p>In order to get a sum of how many number are greater than 0.1, you can do the following:</p>

<pre><code>result = sum(float(line.split()[1]) &gt; 0.1 for line in lines)
</code></pre>

python