1
I am new to the site and I am looking for a solution to my problem. I am currently studying Python 3 and when trying to solve this issue I get an error image, I will put here my code until the current moment and the error message I receive.
soma=0
media=0
while True:
arq1=open('CADASTRO.txt','r')
arq = arq1.readline()
frase=arq.split(',')
frasefinal=frase[2].split('\n')
arq1.close()
if (arq == ''):
break
if (arq != ''):
s=int(frasefinal[0])
soma= s + soma
media+=1
Traceback (Most recent call last): File "C:/List 1 file/questao9.py", line 5, in Arq = arq1.readline() File "C:## Headers ## Appdata Local Programs Python Python37-32 lib encodings cp1252.py", line 22, in Decode def Decode(self, input, final=False): Keyboardinterrupt
In case I’m trying to calculate the age average
Example of line I use in 'REGISTER.txt'
Natural,male,19
Could you put the error message by full? What if you open and close the file every time inside the
while
you will not always read the first line of the file endlessly?– Woss