Python Fancy Tuples Hackerrank Solution