0

my problem is that these two functions (in my opinion the same) one works and the other does not, any suggestions?

fr = open("numeri.txt", "r")

def numMax(file):
    i = 1
    maxNum = 0
    for n in file:
        n = int(n)
        if i == 1 or n > maxNum:
            maxNum = n
        i += 1
    return maxNum

def numMin(file):
    i = 1
    minNum = 0
    for n in file:
        n = int(n)
        if i == 1 or n < minNum:
            minNum = n
        i += 1
    return minNum
    
print("The max is", numMax(fr))
print("The min is", numMin(fr))

fr.close()

The file contents: 20 47 174 29 117 29 29 62 55 71 89 177 27 178 96 -8 116 132 188 63 129

0 Answers0