# ----------------------------------------------
#  Question
#  Write a function count_digits, which expects two arguments:
#  - a positive integer n;
#  - a list d of 10 integers, initialized with zeros;
#  The function counts the number of times a digit 0, 1, 2, ..., 9, occurs in the number n and fills in the list d accordingly.
#  An element at the index i of the list d corresponds to the number of occurrences of digit i.
#  If n is negative or equal to zero, the function should make no changes to the list d.

#  Examples:
#  (1) count_digits(155027, d) modifies the list d as follows: d[0] = 1, d[1] = 1, d[2] = 1, d[5] = 2, d[7] = 1
#  (2) count_digits(8285260, d) modifies the list d as follows: d[0] = 1, d[2] = 2, d[5] = 1, d[6] = 1, d[8] = 2
#  (3) count_digits(1575559, d) modifies the list d as follows: d[1] = 1, d[5] = 4, d[7] = 1, d[9] = 1
# ----------------------------------------------

def count_digits(n, d):
    if n < 1:
        pass
    else:
        while n:
            one_digit = n % 10
            d[one_digit] = d[one_digit] + 1
            n = n // 10

print("Examples:")
digits = [0 for i in range(10)]
#print("\n----------------\n")
count_digits(155027, digits)
print(digits)

digits = [0 for i in range(10)]
#print("\n----------------\n")
count_digits(8285260, digits)
print(digits)

digits = [0 for i in range(10)]
#print("\n----------------\n")
count_digits(1575559, digits)
print(digits)