I found the answer. It was in the call for lambda function. It should be:
for word in words: button = ft.Button(text=word) button.on_click = lambda e, btn=button: click(e, btn) buttons. Append(button)