-1
def main():
filename = input("Enter a file name: ")
with open(filename) as f:
data = [int(line) for line in f]
if len(data) > 2:
print('The smallest number in the file is: ', + min(data))
print('The largest number in the file is: ', "{:,}".format(+ max(data)))
print('The total sum of the number in the file is: ', "{:,}".format(sum(data)))
print('The average from the numbers in the file is: ', "{:,.2f}".format(sum(data)/len(data)))
elif len(data) == 1:
print ('There is only one number in your file to process.')
else:
print('There are no numbers in your file to process.')
f.close()
main()
Tamam soru nedir? – Bahrom
Hata iletisini almaya devam ediyorum: ValueError: base() ile int() için geçersiz literal: boş bir dosya girerken '\ n'. Bunu nasıl aşacağımı bilmiyorum. –
Lütfen bu ayrıntıları soruya ekleyin. – Bahrom