How to find largest number in file and see on which line it is
<p>The file looks like this:</p>

<pre><code>1, a b
2, c d
3, e f
</code></pre>

<p>my current code </p>

<pre><code>b = open('file.txt', 'r')

c = b.readlines()
regels = len(c)

print(regels)
</code></pre>

<p>I got the numbers of lines but still need biggest number + on which line it is. </p>

<p>None of the answers give you the line of the max number so I'll post some quick code and refine later</p>

<pre><code>max_num = 0
line_count = 0
with open('file.txt', 'r') as infile:
    for line in infile:
        number = int(line.split(',')[0])
        if number &gt; max_num:
             max_num = number
             line_num = line_count
        line_count += 1
print (max_num)
print (line_num)
</code></pre>

python