Wrong answer and I do not know why in Python

0

I have a question on the following question:

  

The ages and heights of K students were noted. Make a Program that   determine how many students over the age of 13 have a height below   average height of all students. The entry must contain an N number   in the first line that indicates the number of students in the test case. In   then each line contains age and height.

My code looks like this

idade = []
altura = []
somaAltura = []
cont = 0

qntAlunos = int(raw_input('Informe a quantidade de alunos: '))

for i in range(qntAlunos):
    print 'Informe a idade:'
    idade.append(int(raw_input()))
    print 'Informe a altura:'
    altura.append(float(raw_input()))
    somaAltura = sum(altura)
    media = somaAltura / qntAlunos

for j in range(qntAlunos):
    if altura[j] < media and idade[j] > 13:
        cont += 1


print cont

But when I run the program, does the counter never give the correct answer?

    
asked by anonymous 29.11.2018 / 19:09

1 answer

0

Check your counter. You define it as "cont1 = 0" but use "cont + = 1". Set it to cont = 0, keeping the same variable nomenclature that will work. Hug and good studies.

    
29.11.2018 / 19:14