samedi 2 janvier 2021

How to select a random Entry on a tkinter canvas?

I'm making a simple sudoku generator, and have got 81 different entries (e1, e2, e3, e4 etc). I would like to know if there is any way to select a random entry to insert a number into.

So kind of like this:

num = randint(0, 81)
entry = "e" + str(num)
entry.insert()

With the above code you get an error saying "str object has no attribute 'insert'" which makes sense, but is there any way to 'convert' a string to a variable name?

Thanks in advance,

Romke




Aucun commentaire:

Enregistrer un commentaire