Answer to Question #256678 in Python for Raju

Question #256678

Nested List Indexing


Write a program to print the index of the given number N in the list of tuples.


Sample Input 1 

4

Sample output 1

0 1 


Sample Input 2

15

Sample output 2

1 1


1
Expert's answer
2021-10-27T06:24:46-0400
listTuples=[(4,5,6,5),(3,1,2,7),(9,8,7,5)]
number=int(input())
index=0
for tuple in listTuples:
    for t in tuple:
        if t==number:
            print(index,end=" ")
    index+=1

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS