如何检查列表是否为空?

问题描述:

例如,如果通过以下内容:

For example, if passed the following:

a = []

如何检查a是否为空?

if not a:
  print("List is empty")

使用空的list隐式布尔值相当pythonic.

Using the implicit booleanness of the empty list is quite pythonic.