To find the average of a list of numbers in Python, you can use the following code:
main.py79 chars4 lines
In this example, we have a list of numbers called my_list
. We use the sum()
function to add up all the numbers in the list, and then divide by the length of the list using the len()
function. This gives us the average of the list, which we store in the variable average
. Finally, we print the value of average
.
gistlibby LogSnag