66. Problem to calculate the average of the list.

In this Python list program, we will take a user input as a list and calculate the average of the list with the help of the below-given steps.

Average of the list elements:

Steps to solve the program
  1. Take a list as input.
  2. Create a variable called total.
  3. Add each element of the list in the total variable using for loop.
  4. To find the average divide the total by length of the list.
  5. Print the output to see the result.
				
					#Input list
list1 = [3, 5, 7, 2, 6, 12, 3]

#Creating variable
total = 0

for value in list1:
    total += value
    
#Printing output
print("Average of list: ",total/len(list1))
				
			

output :

				
					Average of list:  5.428571428571429
				
			

Related Articles

Difference between consecutive numbers in list

Count integers in a given mixed list

Leave a Comment