You are assigning to divide
in your function, making it a local variable:
divide +=1
Any other use of divide
before it is first assigned a value will then raise the UnboundLocal
exception.
If you meant it to be a global, tell Python so with the global
keyword:
def nextNumber():
global divide
userInput = input("enter a number to generate factors:\n") #
number = int(userInput)
half = (number / 2)
halfFixed = int(half)
for x in range (0, halfFixed): # make second arg half of user number
result = number % divide
if result == 0:
factors.append(divide)
divide +=1