answer please.....help needed
Attachments:
Answers
Answered by
1
Answer:
see below
Explanation:
# Python code to count the number of occurrences
def countX(lst, x):
count = 0
for ele in lst:
if (ele == x):
count = count + 1
return count
# Driver Code
lst = [2,4,2,7,5 ,3,4,7,2,5]
x = 2
y=3
z=4
a=5
b=7
print('{} has occured {} times'.format(x, countX(lst, x)))
print('{} has occured {} times'.format(x, countX(lst, y)))
print('{} has occured {} times'.format(x, countX(lst, z)))
print('{} has occured {} times'.format(x, countX(lst, a)))
print('{} has occured {} times'.format(x, countX(lst, b)))
Similar questions