Functions · 19 / 27 Exercise Medium

Function to add an array of integers

Objective

Create a Python program that asks the user for 5 integers and stores them in a list. Then, implement a function called add_numbers that receives the list and returns the sum of its elements. Finally, display the result.

Instructions

  • In the main function, ask the user for 5 integers and store them in a list.
  • Implement the function add_numbers with the list as a parameter. It calculates the sum of the numbers.
  • Print the result of the sum on the screen.
Input
5
2
5
3
1
Output
16

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise