Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 394 Bytes

20220906181721.md

File metadata and controls

18 lines (13 loc) · 394 Bytes

any / all built-ins

Use the Python built-ins functions!

  • any(iterable) - Return True if any element of the iterable is true.
  • all(iterable) - Return True if all elements of the iterable are true

Reads like English 😍

>>> names = ("Oscar", "Tamara", "Jim", "April")
>>> any(name.startswith("J") for name in names)
True
>>> all(len(name) > 2 for name in names)
True

#built-ins