What is the most pythonic way to return true if a list is not empty?
def fun(x):
return x != []
Given some function called fun
where we pass in a list x. List could look like []
or [1,3,4]
.
I want to return True if the list is not empty. Am I doing that in the most pythonic way?
The reason I ask is because when I do return x is not None
instead of return x != []
I get a different answer. I guess this is because empty list is not considered null?