Quantcast
Channel: Finding the average of a list - Stack Overflow
Viewing all articles
Browse latest Browse all 26

Answer by superN0va for Finding the average of a list

$
0
0

You can make a function for averages, usage:

average(21,343,2983) # You can pass as many arguments as you want.

Here is the code:

def average(*args):    total = 0    for num in args:        total+=num    return total/len(args)

*args allows for any number of answers.


Viewing all articles
Browse latest Browse all 26

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>