Categories
Mastering Development

is there a way to use same variables in different functions without using global?

check1 = False
def adding():
    global f_num, s_num, check1
    check1 = True
    e.delete(0, END)
    f_num = e.get()

    s_num = e.get()
    e.delete(0, END)

def show_answer():
    if check1:
        e.insert(0,f_num+s_num) 

I’m new to coding and using this website…I’m using tkinter module to build a calculator. when I set the show_answer() function in the equal sign button it was supposed to show the answer to the addition to the numbers.

Leave a Reply

Your email address will not be published. Required fields are marked *