From the course: Python for Non-Programmers

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Solution: Sum of all evens

Solution: Sum of all evens - Python Tutorial

From the course: Python for Non-Programmers

Solution: Sum of all evens

- [Instructor] So for this challenge, I wanted you to determine the sum of all the even numbers. So, you're given a list of ins called numbers, and we can see that on line nine, we've got numbers equal to all these different integer there. And the task is find all the even numbers in the list called numbers, then add all of those even numbers together, return the sum. All of those evens added together. So, first thing that we need to do is figure out which numbers inside of this list are even. And so we are going to be using a for loop to do this. And so let's go ahead and right here we're going to say for and we're going to need a name for the individual number that we're looking at. And I think we just call that number. So we're going to say for number in numbers, with an S, and then we'll do a colon. And this now means this is going to loop through each number in the list and each time number is going to be equal to whatever that particular integer is. And so just to see if this is…

Contents