Python Forum
How to check if my argument is a tuple with 3 tuples
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to check if my argument is a tuple with 3 tuples
#1
So I have this function that will tell me if my argument is a tuple with 3 tuples in it, each of them with 3 digits.
so I'm using a lot of ifs, isinstances and for to do it, something like this:

def f(x):

if isinstance(x, tuple) and len(x) == 3:
____for item in x:
________if isinstance(item, tuple) and len(item) == 3:
______________for i in item:
___________________(code to check check values)
_________________________return True
This however is not working ecause I believe the code isn't going over all items and after the first i from the first item, if it checks out it just returns True. Is this the problem?
Reply


Messages In This Thread
How to check if my argument is a tuple with 3 tuples - by zarox - Nov-15-2020, 06:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to use a tuple as an argument of a function zarox 5 3,650 Nov-14-2020, 08:02 PM
Last Post: buran
  Check common element in tuples PUP280 10 5,895 Nov-05-2020, 05:01 PM
Last Post: PUP280
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 2,847 Nov-04-2020, 11:26 AM
Last Post: Aggam
  SyntaxError: positional argument follows keyword argument syd_jat 3 5,857 Mar-03-2020, 08:34 AM
Last Post: buran
  Being explicit about the items inside a tuple argument rudihammad 3 2,468 Dec-04-2019, 08:10 AM
Last Post: perfringo
  How to get first line of a tuple and the third item in its tuple. Need Help, Anybody? SukhmeetSingh 5 3,218 May-21-2019, 11:39 AM
Last Post: avorane
  Why args type is always tuple, when passed it as argument to the function. praveena 5 5,343 Jan-16-2018, 09:07 AM
Last Post: praveena

Forum Jump:

User Panel Messages

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