Lists · Beginner · 40 XP · about 4 min
Write a function called count_element(lst, element) that counts how many times an element appears in a list.
count_element([1, 2, 2, 3, 2], 2) # Returns 3 count_element(["a", "b", "a"], "a") # Returns 2 count_element([1, 2, 3], 5) # Returns 0
Ready?
Accept the challenge to start writing. A small timer counts the time this page is in view.
Output appears here.