Python Forum

Full Version: What area unit the opposite ways in which to understand if an inventory in Python is
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The easiest approach - if you recognize that the argument is often a listing is :

if list_var:
   print(‘List is not empty’)
else:
   print(‘List is empty’)
This works as a result of Python variables have the construct of ‘truthiness’: id est they'll be used if they need a True/False price.

List that area unit empty area unit thought-about to be False (or ’Falsey’) and then you'll use it as within the on top of snipping.

The on top of may be a quite common idiom: you'll usually see it or it’s equivalent in several places.
Huh ? Think
double huh??