Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Easy Unpack by vlad.bezden
"""
Easy Unpack.
Your mission here is to create a function that gets an tuple
and returns a tuple with 3 elements -
first, third and second to the last for the given array
Input: a list of strings.
Output: a string.
"""
def easy_unpack(elements: tuple) -> tuple:
"""
Returns a tuple with 3 elements - first, third and second to the last
"""
return (elements[0], elements[2], elements[-2])
if __name__ == '__main__':
assert easy_unpack((1, 2, 3, 4, 5, 6, 7, 9)) == (1, 3, 7)
assert easy_unpack((1, 1, 1, 1)) == (1, 1, 1)
assert easy_unpack((6, 3, 7)) == (6, 7, 3)
Oct. 1, 2018