Python Forum
Tuple help! - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Tuple help! (/thread-31076.html)

Pages: 1 2


RE: Tuple help! - buran - Nov-23-2020

(Nov-22-2020, 10:49 PM)chiron Wrote: easy_unpack((1, 2, 3, 4, 5, 6, 7, 9)) == (1, 3, -2)
You post this for second time (as a comment, preceeded by#). What exactly do you think it does? == is equality operator. On right-hand side is tuple with 3 elements and on left-hand side easy_unpack function called. So basically this is comparison of the result of the function call (object returned by the function) and some tuple.


RE: Tuple help! - chiron - Nov-24-2020

@buran I thought it would return the numbers 2, 4, 7. I assumed that the easy_unpack function uses the index provided along with the numbers following the equality operator (new term to me) to produced 2, 4, 7. Obviously that doesn't make much sense now but that was the first thing I thought of when I first read the instructions which is what I mean by saying I'm reading this/understanding this incorrectly


RE: Tuple help! - buran - Nov-24-2020

(Nov-22-2020, 08:11 AM)buran Wrote: For a more versatile function in may take second argument - tuple of indexes you want to get, in the order you want them. This way it will not have indexes it returns hard-coded. But this is not required for this assignment.
I already mentioned that you can make the function have second parameter, but it's not required for this assignment. They have provided you with the signature of the function and it is expected to have just one parameter def easy_unpack(elements: tuple) -> tuple:

It looks like you will benefit from following some sort of tutorial. Check.io and similar are good for practice, but not as only study source. I think it's not about how you think, but you just lack understanding of some basic concepts.