How do I check if a list is empty?
The pythonic way to do it is from the PEP 8 style guide (where Yes means “recommended” and No means “not recommended”):
For sequences, (strings, lists, tuples), use the fact that empty sequences are false.
Yes: if not seq: if seq:No: if len(seq): if not len(seq):