What is the problem with this code? The last button that is created is always the one that is clicked!
import flet as ft
def main(page: ft.Page):
def click(e, button: ft. Button):
button.bgcolor = ft.Colors.YELLOW
button.page.update()
words = ['ma', 'ti', 'ke', 'to', 'pe', 'la', 'su']
buttons = []
for word in words:
button = ft.Button(text=word)
button.on_click = lambda e: click(e, button)
buttons.append(button)
page.add(ft.Row(buttons))
ft.app(main)