Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading