Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Easy Unpack solution in Clear category for Easy Unpack by ajevip
def easy_unpack(elements: tuple) -> tuple:
"""
returns a tuple with 3 elements - first, third and second to the last
"""
a = elements[0] # first element of the tuple.
b = elements[2] # third element of the tuple.
c = elements[-2] # second element to the last.
return (a, b, c) # tuple to return.
if __name__ == '__main__':
print('Examples:')
print(easy_unpack((1, 2, 3, 4, 5, 6, 7, 9)))
#These "asserts" using only for self-checking and not necessary for auto-testing
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)
print('Done! Go Check!')
Oct. 13, 2019
Comments: