Function to count tuple elements
Question
Suppose you are given a tuple containing ints and strings. Write a Python function to return the # of times a given element, n
, appears in the tuple.
For example, given the tuple below, where n=3
, your function should return 4
, since 3 appears 4 times in the tuple.
input:
n = 3
my_tuple = 2, 'my_string', 4, 3, 3, 3, 2, 3
output:
4