Skip to content

Latest commit

 

History

History
43 lines (26 loc) · 630 Bytes

Number_Of_Occurrences.md

File metadata and controls

43 lines (26 loc) · 630 Bytes

CodeWars Python Solutions


Number Of Occurrences

Write a functionthat returns the number of occurrences of an element in an array.

Examples

sample = [0, 1, 2, 2, 3]
number_of_occurrences(0, sample) == 1
number_of_occurrences(4, sample) == 0
number_of_occurrences(2, sample) == 2
number_of_occurrences(3, sample) == 1

Given Code

def number_of_occurrences(element, sample):
    pass

Solution

def number_of_occurrences(element, sample):
    return sample.count(element)

See on CodeWars.com