Inside your function when you say word=word+1, actually the word variable after the equal sign won't be found since you are altering it already in the expression assignee. To overcome this issue there are two solutions, you either use global (which is not recommended) or first try to save the word and digit value in local variables then use them in your expression, see below sample code:
w = word
d = digit
for each in a:
word, digit = letter("Hello123")
This could be confusing at start, perhaps you need to read about variable scopes in Python.