Do things step by step. Try to isolate problems.
First thing, the problem says it will be necessary to use the height average, so first thing, calculate the height average and store in a variable.
After that, you need to iterate over the first list (of ages) and for each iterated element check if it eh > that 13 (if element > 13: ....)
Once this is done, just use the iterated element’s Input to find its corresponding height and check if it is smaller than the average. To find the corresponding height you can use alturaAlunos[idadeAlunos.index(elemento)]
where element will be the element being iterated in the loop.
Last hint, use a loop for
to iterate on the list idadeAlunos
.
Post your code in case you’ve managed to solve the problem, if you can’t, post so I can help you solve.
Whenever you’re working with Python (or any other language) search the internet for functions that can help you, you’ll almost always have something that does what you want in just one line in Python.
Example: you declared a variable and made a for loop to calculate the sum of the heights. This could be solved by playing on google "how do I calculate the sum of the elements of a list in python".
Answer: sum(nome_da_lista)
In your case: media = sum(nome_da_lista)/len(nome_da_lista)
Start by studying algorithms. Clearly you have a lot of difficulty in structuring any desired logic. Then calculate the average height.
– Woss