Any Check in Python
Level 256 keystrokes
This checks if any element satisfies a condition. The any() function returns True if at least one element is truthy.
Python code
# Create a list with mostly odd numbers and one even1nums = [1, 3, 4, 7]# any() checks if at least one element satisfies the condition# 4 is even (4 % 2 == 0), so it returns True2print(any(n % 2 == 0 for n in nums))Output
True
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
,× 3=× 3(× 2)× 2[× 1]× 1%× 1