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
- Take a list as input.
- Create a variable called total.
- Add each element of the list in the total variable using for loop.
- To find the average divide the total by length of the list.
- 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
Python program to count integers in a given mixed list.
Python program to access multiple elements of the specified index from a given list.
Python program to check whether a specified list is sorted or not.
Python program to remove duplicate dictionaries from a given list.
Python program to check if the elements of a given list are unique or not.
Python program to remove duplicate sublists from the list.