From the course: Python: Recursion

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Recursive sum function in Python

Recursive sum function in Python - Python Tutorial

From the course: Python: Recursion

Start my 1-month free trial

Recursive sum function in Python

- [Instructor] In this video, we're going to use recursion to find the sum of integers stored in a Python list. Where we use Python slice notation, to make this algorithm work. Let's just quickly review that notation now. So I'm going to hit F12, in PyCharm, and type in Python because I know Python is in my path, so I can enter interpreter mode, and I can just type Python commands into a terminal. Which is quite useful to do. Particularly if you just want to check out some little detail of the language before integrating it into an actual program. So let's say my list. Set it equal to some integers. So three, two, six, four, for example. And then if I want to access a particular item in the list, probably fairly familiar, you just use the square brackets, and that will give you the item at position zero. That gives me the three. However, slice is a slightly different. So if I do my list and I do a one colon two, that…

Contents