how to average in python with loop

Solutions on MaxInterview for how to average in python with loop by the best coders in the world

showing results for - "how to average in python with loop"
Yannick
22 May 2018
1list = input('Input a list of numbers separated by comma then space:\n ')
2try:
3    list = list.split(', ')
4    sum = 0
5    
6    for number in list:
7        sum = int(number) + sum
8
9    avg = sum / len(list)
10    print('The average of the numbers you entered is: ', avg)
11except ValueError:
12    print('Please enter a list of number separated by a comma and space only')