Hi guys im making a memory game but i need to add random letter to buttons and if some button have same letter it will turn green and if not it will turn red. i will send here only 2 buttons because i have 27 buttons in my code but i only need help with the button color and that i dont want to repeat letters more than 2

from tkinter import *
import random
import time

root = Tk()

name = root.title('Pexeso')

text = ["A","B","C","D","E","A","B","C","D","E"]

button1 = Button(root, text="", width = 20, height = 10)
button2 = Button(root, text="", width = 20, height = 10)

button1.grid(row=0 , column=0)
button2.grid(row=0 , column=1)

def random_text_fun1():
    if button1["text"] == "":
        button1["text"] = random.sample(text, k=1)

def random_text_fun2():
    if button2["text"] == "":
        button2["text"] = random.sample(text, k=1)

root.mainloop()

If the question is "how do I change the background color" then the answer is

button1.configure(bg = "red")

or

button1.configure(bg = "green")
commented: I see what you did there. "Red Green." Great show. +15