Nov-21-2020, 04:24 AM
Complete beginner to all things programming, let alone python. I'm looking to numerous sources to help me out learning but I'm struggling big time. I think part of the reason is that I'm not reading/interpreting the questions correctly. Here is a tuple exercise I'm struggling with from the learning game CheckiO:
def easy_unpack(elements: tuple) -> tuple:
returns a tuple with 3 elements - first, third and second to the last
When I read this, based on what I've learned thus far, my thinking is:
"Three elements of the 1st, 3rd, and 2nd to last means -1, -3, -2."
Therefore my code is:
# easy_unpack((1, 2, 3, 4, 5, 6, 7, 9)) == (-1, -3, -2)
return (9, 6, 7)
This is wrong, however. Why?
def easy_unpack(elements: tuple) -> tuple:
returns a tuple with 3 elements - first, third and second to the last
When I read this, based on what I've learned thus far, my thinking is:
"Three elements of the 1st, 3rd, and 2nd to last means -1, -3, -2."
Therefore my code is:
# easy_unpack((1, 2, 3, 4, 5, 6, 7, 9)) == (-1, -3, -2)
return (9, 6, 7)
This is wrong, however. Why?