Answer to Question #324250 in Python for Nuhan Habib

Question #324250

Write a python program that takes an input from the user and finds the number of times that the



input is present in a given tuple.



===================================================================



Example 1:



Given tuple: (10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2)



Sample Input 1:



8



Sample Output 1:



8 appears 4 times in the tuple



===================================================================



Example 2



Given tuple: (10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2)



Sample Input 2:



1



Sample Output 2:



1 appears 0 times in the tuple



===================================================================




1
Expert's answer
2022-04-05T13:17:43-0400
t = (10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2)
try:
    find = int(input(">> "))
    print(find, "appears", t.count(find),"times in the tuple")
except Exception:
    print("Try again!")

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