Task
Check if all digits of the given integer are even.
Example
-
For
n = 248622, the output should beevenDigitsOnly(n) = true; -
For n = 642386, the output should be
evenDigitsOnly(n) = false.
Input/Output
-
[execution time limit]
4 seconds (py3) -
[input] integer n
Guaranteed constraints:1 ≤ n ≤ 109. -
[output] boolean
trueif all digits ofnare even,falseotherwise.
My Solution
def evenDigitsOnly(n):
return all([int(digit) % 2 == 0 for digit in str(n)])