As you know the Programmation, in general, has two types of writing, good and bad code.
in this article, we will write good and bad code to check if the variable is empty
checking if variable is empty [Good way]
In this example, we'll check if the variable "var" is empty.
#empty variable var = "" #check if variable is empty if not var: print("yes it is!")
yes it is!
as you can see, "var" is empty
checking if variable is empty [Bad way]
In this example, we will do the same thing as the first example, but now in the wrong way
#empty variable var = "" #check if variable is empty if len(var) == 0: print("yes it is!")
yes it is!
As you can see, the code is working very well, but in the worst way because we don't need "len" function,
remind, your coding should be short, clean and easy to read
In this article, we have learned how to check empty variables, so you should code as example 1 if you want to check empty variables, list and tuple.
English today is not an art to be mastered it's just a tool to use to get a result