We will write a script that takes a list of numbers and prints the total and the average.
The idea
Store the numbers in a list, add them up with sum(), and divide by len() to get the average.
Tutorial · 8 min read · sample article
A tiny program that reads a list and summarizes it, with every line explained.
We will write a script that takes a list of numbers and prints the total and the average.
Store the numbers in a list, add them up with sum(), and divide by len() to get the average.