[Python] How do I make the numbers do their operation? Is there any module that can do that?

Discussão em 'Python' iniciado por Stack, Março 8, 2025.

  1. Stack

    Stack Membro Participativo

    def equalizer(entryblock):
    x = entryblock.get()
    entryblock.delete(0, tk.END)
    entryblock.insert('end', int(x))


    so here is a function for my tkinter calculator. I am trying to make a function where it takes the entry box and does the operations and gives the result. For example, if I punch in '1+2+3', I want this function to turn it into 6. Whenever I try this, it gives this error:

    ValueError: invalid literal for int() with base 10: '1+2+3'


    Could I use the math module to fix this problem?

    Continue reading...

Compartilhe esta Página