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>Iterate through the file and keep track of the highest number you've seen and the line you found it on. Just replace this with the new number and new line number when you see a bigger one.</p>

<pre><code>b = open('file.txt', 'r')
max = -1
lineNum = -1
line = b.readline()
index = 0
while(line):
    index+=1
    newNum = line[0]
    if(newNum&gt;max):
        max = newNum
        lineNum = index
    line = b.readline()
print lineNum,max,index
</code></pre>

<p>max is your highest number, lineNum is where it was, and index is the number of lines in the file</p>

python