How to count the items in tuple till the first sub tuple in Python

1 Answer

0 votes
tpl = (6, 8, 9, 5, (0, 9), 7, 1) 
  
for count, i in enumerate(tpl): 
    if isinstance(i, tuple): 
        break
  
print(count) 


'''
run:

4

'''

 



answered Dec 18, 2019 by avibootz

Related questions

1 answer 176 views
4 answers 286 views
1 answer 181 views
2 answers 194 views
...