True for all characters in a string

In Python 3, what's the shortest way to check if a predicate is true for all characters in a string?

+5
source share
2 answers
all(predicate(x) for x in string)
+13
source
all(map(predicate, string))

Functionally the same as @Abe answer, but with a map instead (also lazy in python3)

+2
source

All Articles