I am comparing fist element of list vs all the elements of list. If False is there I need to return false or if all are true, I need to return True. Currently I am doing this with if-else
. is there any pythonic way to return bool
value
def checker(inp):
_compare = [ _==inp[0] for _ in inp]
return False if False in _compare else True
lst = [5, 5, 5]
lst2 = [5, 5, 6]
# Case 1
level = checker(inp=lst)
print(level)
True
# Case 2
level2 = checker(inp=lst2)
print(level2)
False
Any pythonic way to achieve this
return False if False in _compare else True