From the course: Advanced Python

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Using Iterators

Solution: Using Iterators - Python Tutorial

From the course: Advanced Python

Solution: Using Iterators

- [Instructor] Alright, so to find the largest number in multiple lists of numbers, we need to do two things. First, we need to be able to search all of the lists. There are a few different ways you could solve this problem, but for my solution, I chose to use the chain.from_Iterable function, which is in the ITER tools module. That function will take the list of lists that we are given and iterate over all of the values, iterating over each list, after it exhausts the previous list, then all you need to do is wrap that function call with a call to the built-in max function, which will find the largest number. So let's go ahead and run that, and you can see that my code has found the largest number, which is 92, which is somewhere in here. I'm not sure exactly where it other is. It's right there. Let's try changing another number to make it the largest number. So let's make this 125 and then let's run the code again. And now you can see that we're returning 125 as the largest number…

Contents