Counting a digit

Write code · Medium · §1.1 Digits

Complete the function solution, which returns how many times the digit d appears when the non-negative integer n is written in base 10.

Function

solution(n, d)

Constraints

Examples

ndresult
70707073
12340

Starter code

def solution(n, d):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.