检查列表是否为空

列表的空白与布尔 False 相关联,因此你不必检查 len(lst) == 0,而只需检查 lst 或 not lst

lst = []
if not lst:
    print("list is empty")

# Output: list is empty