Write a lambda function that counts the number of times a character appears in a string.
Example 1:
Input: 'hello', 'l'
Output: 2
Example 2:
Input: 'world', 'o'
Output: 1
Use a lambda function and the count method of python strings.
# Define the lambda function
count_char = lambda s, c: s.count(c)
# Test the function
print(count_char('hello', 'l')) # Output: 2
print(count_char('world', 'o')) # Output: 1
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.