Skip to content

Latest commit

 

History

History
41 lines (23 loc) · 741 Bytes

Two_Oldest_Ages.md

File metadata and controls

41 lines (23 loc) · 741 Bytes

CodeWars Python Solutions


Two Oldest Ages

The two oldest ages function/method needs to be completed. It should take an array of numbers as its argument and return the two highest numbers within the array. The returned value should be an array in the format [second oldest age, oldest age].

The order of the numbers passed in could be any order. The array will always include at least 2 items.

Examples

two_oldest_ages([1, 3, 10, 0]) # should return [3, 10]

Given Code

def two_oldest_ages(ages):
    pass

Solution

def two_oldest_ages(ages):
    return sorted(ages)[-2:]

See on CodeWars.com