python durchschnitt liste
sum(l) / len(l)
Here is what the above code is Doing:
1. We’re creating a function called average that takes a list of numbers as an argument.
2. We’re creating a variable called length and setting it to the length of the list.
3. We’re creating a variable called sum and setting it to 0.
4. We’re creating a for loop that goes through each number in the list and adds it to sum.
5. We’re dividing sum by length to get the mean.
6. We’re returning the mean.