How to count the number of elements with a specific value in a tuple with Python

2 Answers

0 votes
t = ('java', 'python', 'java', 'c', 'php', 'c++')

print(t.count('java'))


'''
run:

2

'''

 



answered Oct 31, 2018 by avibootz
0 votes
t = (1, 4, 7, 3, 7, 7, 8)

print(t.count(7))


'''
run:

3

'''

 



answered Oct 31, 2018 by avibootz
...