Home >Backend Development >Python Tutorial >Confused with message boxes

Confused with message boxes

WBOY
WBOYforward
2024-02-09 21:10:041098browse

Confused with message boxes

Question content

I'm trying to make my program use tkinter's message box. So far it's working, but now I'm having trouble getting it to include a math equation in the title.

This is my code

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

I also tried it

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

and

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

The first two it gives an error but the last one it gives the answer to my question but I want it to say something like (8*4)


Correct answer


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

use

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

The above is the detailed content of Confused with message boxes. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete