0
I have the txt file:
NOME,n1,n2
JOAO,8,5
MARIA,5,6
PEDRO,0,9
I want to add up the numbers, I did it this way:
arq=open('pergunta.txt','r')
conteudo=arq.readlines()
arq.close()
for i in conteudo:
a=i.split(',')
b=a[1].replace('n1','')
c=a[2].replace('n2','')
print(int(b+c), end='')
In print when not using the int comes out like this:
85
56
09
When using the int in print the following error appears:
ValueError: invalid literal for int() with base 10: '\n'
makes int(b)+int(c) that should work
– Math