0
Good afternoon, I need to solve the following problem using the While structure:
Given a sequence of real values, calculate your average.
The command given by the teacher was:
while True:
try:
valor = float(input())
# processar o valor
except EOFError:
break
And I developed the following code:
while True:
try:
n = input()
seq_break = n.split(',')
armazena = 0
cont = 0
for val in seq_break:
armazena += float(n)
cont += 1
a = (armazena/cont)
print(a)
except EOFError:
break
Meanwhile, I’m having trouble getting out. Instead of returning me the average of the values (expressed in variable a) it is returning me either all the input values or the last value. I don’t know where I’m going wrong.
Are you running this program for some platform that the teacher made available?
– Woss