Does anyone know how I can change this code for it to also print the average of the numbers that are being inputted by the user? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Does anyone know how I can change this code for it to also print the average of the numbers that are being inputted by the user?

total=0 count=0 while count<5: total += int(input("Please enter a number")) count +=1 print("The total is", total)

23rd Dec 2019, 4:26 PM
Esteban Rueda
Esteban Rueda - avatar
1 Answer
+ 1
total=0 count=0 while count<5: num = int(input("Please enter a number")) total += num count +=1 average = total/5 print("The total is", total) print("The average number is",average) #If this is what you were lookig for. #idk if this works, it should.
23rd Dec 2019, 4:36 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar