When you have an empty list a = []
as follows:
Please tell me how to find out if a is empty or not.
An empty sequence (string, list, or tuple) has a false value Therefore, you can use it as follows:
if not a:
print "List is empty"
python style guide recommends the following methods.
Recommended method)
if not seq:
if seq:
Not recommended)
if len(seq):
if not len(seq):
543 Uncaught (inpromise) Error on Electron: An object could not be cloned
747 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
552 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
551 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.