This program is designed to be fed a number and generate all of it's prime factors. I had this working without using any functions earlier, but now I am trying to implement them to get more functionality in my program.
divide = 2
factors = []
def nextNumber():
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
nextNumber()
print (factors)
When I try to run it, the input command is read and I can input a number but as soon as I do I get the error, "UnboundLocalError: local variable 'divide' referenced before assignment" Any help at all would be great thanks.