colored pencil lined up on top of white surface
Photo by Jess Bailey on Unsplash

One of the main uses of methods in any programming language is the opportunity to simply implement a functionality once and then use it as many times as you need.

In a lot of cases, you are supposed to call these functions with actual parameters that are then expected to be used inside the method.

For example, let us say that we want to implement a method in which we add 2 numbers only if they are even numbers:

Now, there is a trick that allows us to extract elements from a list in Python using the symbol “*” in front of the list when calling the method. 

We can use this trick to call the method above by passing all the parameters as a list.

Here it is in action:

This works for any list size that we want. 

Here is another example using a list with three numbers:


That’s it for this article.

I hope you find it useful.