if listA== [ ] more simplified version
This question already has an answer here:
Empty lists evaluate as falsy, so you can also do this, which is what PyCharm may be talking about:
if not listA:
return "yes!"
There are some side effects since the above code will return "yes!" whenever list is False
, an empty string ( ""
), None
, an empty dict ( {}
), an empty set ( set()
) and basically anything else that python treats as falsy
上一篇: 你如何检查列表是否空白?
下一篇: 如果listA == []更简化版本