Python: determine if all items of a list are the same item [duplicate]

def all_same(items):
    return all(x == items[0] for x in items)

Example:

>>> def all_same(items):
...     return all(x == items[0] for x in items)
...
>>> property_list = ["one", "one", "one"]
>>> all_same(property_list)
True
>>> property_list = ["one", "one", "two"]
>>> all_same(property_list)
False
>>> all_same([])
True

Leave a Comment