# How Sum All the Elements in an array using Python

In this tutorial, we will program 'How to Sum All the Elements in an Array using Python'. We will learn how you can sum the element values. The main goal here is to create a program that can actually get the sum of the elements in an array. I will provide a sample program to demonstrate the actual coding of this tutorial.

This topic is very easy to understand; just follow the instructions I provide, and you can also do it yourself with ease. The program I will show you covers the basics of programming for getting the sum of the array elements. I will do my best to provide you with the easiest way for computing elements. So, let's start with the coding.

## Creating Main Function

This is the main function of the application. The following code will display a simple GUI in terminal console that will display program. To do this, simply copy and paste these blocks of code into the IDLE text editor.
`ret = False     while True:   print("\n================== Sum All the Elements in an array ==================\n\n")    arr=[]    num1 = int(input("Enter a number 1: "))   arr.append(num1)   num2 = int(input("Enter a number 2: "))   arr.append(num2)   num3 = int(input("Enter a number 3: "))   arr.append(num3)   num4 = int(input("Enter a number 4: "))   arr.append(num4)   num5 = int(input("Enter a number 5: "))   arr.append(num5)    sum = 0;        for i in range(0, len(arr)):          sum = sum + arr[i];        print("\nSum of all the elements of an array: " + str(sum));        opt = input("\nDo you want to try again?(yes/no): ")    if opt.lower() == 'yes':      ret=False   elif opt.lower() == 'no':      ret=True      print("Exiting program....")    else:      print("Please enter yes/no:")      break    if ret == False:      continue`

This Python script prompts the user to input five numbers, stores them in an array, and then calculates the sum of all the elements in the array. After displaying the sum, it asks the user if they want to try again or exit the program.