Returning several values from a single function call: BEHIND THE SCENES!
Hi! Welcome to this new session where we will learn HOW TO RETURN SEVERAL VALUES FROM A FUNCTION! Let’s get started! What we’ve learned so far is that we can return a value from a function to the scope that called the function and then save it to a variable for later use. But… what if we want to return more than one value? This is where our newly discovered friends come into play , TUPLES AND LISTS! If we return a tuple or a list from a function, we can return several values and assign them individually to their corresponding variables (We will see this in detail in the next diagrams). We’ve learned that we can display the values returned by a function using print(). Since lists and tuples are iterables, we can iterate over their elements using a for/in loop like the examples below. We can also access each individual element by its corresponding index. But… wait a minute! What if we want to store the values returned by the function