Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tuple help!
#1
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?
Reply


Messages In This Thread
Tuple help! - by chiron - Nov-21-2020, 04:24 AM
RE: Tuple help! - by bowlofred - Nov-21-2020, 04:59 AM
RE: Tuple help! - by buran - Nov-21-2020, 07:01 AM
RE: Tuple help! - by chiron - Nov-21-2020, 05:12 PM
RE: Tuple help! - by bowlofred - Nov-21-2020, 07:15 PM
RE: Tuple help! - by buran - Nov-21-2020, 07:29 PM
RE: Tuple help! - by chiron - Nov-21-2020, 10:19 PM
RE: Tuple help! - by buran - Nov-22-2020, 08:11 AM
RE: Tuple help! - by chiron - Nov-22-2020, 10:49 PM
RE: Tuple help! - by bowlofred - Nov-23-2020, 03:27 AM
RE: Tuple help! - by buran - Nov-23-2020, 05:11 AM
RE: Tuple help! - by chiron - Nov-24-2020, 04:58 AM
RE: Tuple help! - by buran - Nov-24-2020, 06:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 2,847 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,217 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