For school we have to make a code which shows the average of a certain list into another list but for some reason my list which should show the smaller numbers is empty, I don't know if it is possible but I tried using an extra variable which counts +1 to itself
from random import randint
kleiner = []
list = []
teller = 0
aantal = int(input("Hoeveel random getallen wilt u? "))
veelvoud = int(input("Welke veelvoud? "))
while len(list) < aantal:
getal = randint(1, 100)
if getal % veelvoud == 0:
list.append(getal)
gemiddelde = sum(list) / len(list)
while len(list) < aantal:
if list[teller] < gemiddelde:
kleiner.append(list[teller])
teller += 1
print(list)
print(list[::-1])
print(kleiner)
help is appreciated in advance.
Aucun commentaire:
Enregistrer un commentaire