You commented: [...] also the negative value is being accounted for in the sum.
This happened because as soon as you get the user value, you did the following:
valores = int(input('Valores: '))
tempos.append(valores)
In this case the correct is first you evaluate the user input and only then add it.
valores = int(input('Valores: '))
if valores < 0:
break
tempos.append(valores)
You also commented: I already put the out to go through the list but not printa
Sorry but I don’t understand why you need to go through everything again with each user input:
for c in range(tempos):
if tempos < media:
print(f'{tempos:}')
But before I give you a suggestion for that, I want to let you know which times are a list variable. In this case if you want to go through the items just use you:
for c in tempos:
I have a suggestion that should meet what you need and will become simpler:
tempos = []
while True:
valor = int(input('Valor: '))
if valor < 0:
break
tempos.append(valor)
media = sum(tempos) / len(tempos)
print(f'MEDIA: {media}')
if valor < media:
print(f'O valor {valor} está abaixo da média: {media}')
Note that I used sum to have Python add the stored values and Len to count how many items I have in the list.
I put it this way more in order to teach you that there are functions in Python that can help you in these mathematical operations.
I hope I helped you.
print(f'tempo abaixo da media:{c}')
that’s it?– Augusto Vasques
when editing unintentionally I removed the variable, even putting the C variable gave the error: 'list' Object cannot be Interpreted as an integer
– Ana Carolina