Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tuple help!
#11
(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.
chiron likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#12
@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
Reply
#13
(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.
chiron likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 2,803 Nov-04-2020, 11:26 AM
Last Post: Aggam
  How to get first line of a tuple and the third item in its tuple. Need Help, Anybody? SukhmeetSingh 5 3,187 May-21-2019, 11:39 AM
Last Post: avorane

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020