Skip to content

Latest commit

 

History

History
49 lines (26 loc) · 664 Bytes

Odd_or_Even.md

File metadata and controls

49 lines (26 loc) · 664 Bytes

CodeWars Python Solutions


Odd or Even?

Given a list of numbers, determine whether the sum of its elements is odd or even.

Give your answer as a string matching "odd" or "even".

If the input array is empty consider it as: [0] (array with a zero).

Examples

odd_or_even([0])          ==  "even"
odd_or_even([0, 1, 4])    ==  "odd"
odd_or_even([0, -1, -5])  ==  "even"

Given Code

def odd_or_even(arr):
    pass

Solution

def odd_or_even(arr):
    return "odd" if sum(arr) % 2 != 0 else "even"

See on CodeWars.com