Files

20 lines
506 B
Python

# HumanEval/155
# Loki Mode Multi-Agent Solution
# Attempts: 1
# Passed: True
def even_odd_count(num):
"""Given an integer. return a tuple that has the number of even and odd digits respectively.
Example:
even_odd_count(-12) ==> (1, 1)
even_odd_count(123) ==> (1, 2)
"""
even_count = 0
odd_count = 0
for digit in str(abs(num)):
if int(digit) % 2 == 0:
even_count += 1
else:
odd_count += 1
return (even_count, odd_count)