ScanSkill

all

This all() function returns a Boolean value that indicates whether the collection contains only values that evaluate to True.

Syntax

all(iterable)

Here,

  • collection: Required. Any iterable type(list, tuple, dictionary, etc.)

Note: If the iterable is empty, all() returns True.

Examples

  • With True, False
>>> all([])
True
>>> all([True, False])
False
>>> all([True, True])
True
  • With strings, tuples, lists, dictionaries
>>> all('True')
True
>>> all("cloudyfox")
True
>>> all('False') # note that non-empty strings are always True
True
>>> all([0, 1])
False
>>> all([1, 1])
True
>>> all((1, 1))
True
>>> all((1, 0))
False
>>> all({0: 'zero', 1: 'one'})
False
>>> all({1: 'one', 2: 'two'})
True
>>> all({0, 1})
False
>>> all({1, 1})
True