Q
Q
qetuo32020-07-14 17:58:32
Python
qetuo3, 2020-07-14 17:58:32

Why doesn't the max method output the maximum value?

*********input.txt***************
100 500 1000

************************ ******
fin = open('input.txt',)
fout = open('output.txt','w')

a = []
a = fin.readline().split(' ')

fg = min(a)
fgt = max(a)
print('min =' , fg, ',' , ' max =' , fgt)

fin.close()
fout.close()

********output. txt**********
min = 100 , max = 500

******************************

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
User Unknown, 2020-07-14
@qetuo3

Because you don’t have numbers, but strings, you must first translate each into a number

for i in range(len(a)):
     a[i] = int(a[i])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question