pythontkintermessagebox

Confused with messagebox


I am trying to have my program use messagebox from tkinter. So far it's worked, but now I'm having a problem getting it to have a math equation in the title.

This is the code I have

while lives >= 0:
  x = random.randrange(1, 12)
  y = random.randrange(1, 12)
  name = numinput(x"*"y, "Answer:", minval=1, maxval=144)`

and I've also tried

name = numinput("x"*"y", "Answer:", minval=1, maxval=144)

and

name = numinput(x*y, "Answer:", minval=1, maxval=144)

with the first two it gives an error, but with the last one it says the answer to my problem, but I'm wanting it to say something like (8*4)


Solution

  • The title is a string, but all your tries are not strings.

    Use

    name = numinput(f"{x} * {y}", "Answer:", minval=1, maxval=144)