{"id":9607,"date":"2021-09-30T17:30:37","date_gmt":"2021-09-30T12:00:37","guid":{"rendered":"https:\/\/python-programs.com\/?p=9607"},"modified":"2021-11-22T18:33:32","modified_gmt":"2021-11-22T13:03:32","slug":"python-program-to-find-the-sum-of-elements-in-a-list-recursively","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-the-sum-of-elements-in-a-list-recursively\/","title":{"rendered":"Python Program to Find the Sum of Elements in a List Recursively"},"content":{"rendered":"

Don’t stop learning now. Get hold of all the important Java fundamentals with the Simple java program example<\/a> guide and practice well.<\/p>\n

Lists in Python:<\/strong><\/p>\n

A list is a Python data type that can be used in a variety of ways. A list is made up of comma-separated values, which are referred to as list items. Within square brackets, a list is declared. It’s worth noting that elements in a list don’t have to be of the same type.<\/p>\n

Recursion:<\/strong><\/p>\n

If you’re familiar with Python functions, you’ll know that it’s typical for one function to call another. It is also feasible for a function in Python to call itself! A recursive function calls itself, and the process of using a recursive function is known as recursion.<\/p>\n

Although it may appear strange for a function to call itself, many sorts of programming challenges are better stated recursively.<\/p>\n

Given a list, the task is to find the sum of the list using recursion in Python.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given list = 9, 1, 27, 48, 91, 93, 99, 27, 29, 33, 39, 19, 11, 27, 29, 35, 39, 12, 65, 69, 67<\/pre>\n

Output:<\/strong><\/p>\n

The sum of the given list\r\n [9, 1, 27, 48, 91, 93, 99, 27, 29, 33, 39, 19, 11, 27, 29, 35, 39, 12, 65, 69, 67] \r\nwith size  21  = 869<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given list =11 13 21 85 34 96 75 73 14 25 37 39 49 47 65 69 63 21 29 123 456 789<\/pre>\n

Output:<\/strong><\/p>\n

The sum of the given list\r\n[11, 13, 21, 85, 34, 96, 75, 73, 14, 25, 37, 39, 49, 47, 65, 69, 63, 21, 29, 123, 456, 789] \r\nwith size 22 = 2234<\/pre>\n

Program to Find the Sum of Elements in a List Recursively in Python<\/h2>\n

Below are the ways to Find the Sum of Elements in a List using the recursive approach in Python:<\/p>\n