python check if variable has value

if variable:
  # code goes here...

Here is what the above code is Doing:
1. It’s checking if the variable is True.
2. If it is, it runs the code inside the if statement.
3. If it’s not, it skips the code inside the if statement.

You can also use the ‘else’ keyword to run some code if the condition is not True.

if variable:
# code goes here…
else:
# code goes here…