Write a Python function that takes a string as input and counts the number of occurrences of each character in that string.
String: 'python'
def count_characters(string):
    counts = {}
    for s in string:
        counts[s] = counts.get(s, 0) + 1
    return counts

result = count_characters('python')
print(result)