Showing posts with the label Placeholder

Python placeholder '_' Top Ideas to Use it Perfectly

In Python, you can call the underscore ( _ ) operator placeholder. The prime purpose is you can mask the variable that you don't use in a function. Python placeholder  Purpose of Placeholder The purpose is you can mask a few variables. This makes your code is readable. So in the future, you can replace placeholders with variable names you want. How to Use Placeholder in a Function I have explained in three steps how to use placeholder correctly. Code to create a Function Logic to use placeholder Logic to use two placeholders 1. Code to create a Function. def function_that_returns_multiple_values(x):        return x*2, x*3, x+1        for i in range(0,5):             square, cube, added_one = function_that_returns_multiple_values(i)             print(square, cube) In the above logic, in print, it returns only two variables. Therefore you can mask the third variable with an underscore.  Thus your code looks beautiful. 2. Logic to use Placeholder def function_that_returns_multiple_v