non global to global

i Have:


def Add():
    global NoOfButtons

    To_Exec = "Button"+str(NoOfButtons)+" = "+"Whatever"
    exec To_Exec
 
   NoOfButtons += 2

    #For Debug
    print Button2

prints out:

Whatever

in another def function:


def Function():
    global NoOfButtons

    if NoOfButtons >= 2:
        global Button2
        print Button2


if crashes when i call the above function
how do i get it to work?