So I am making a program that ask the users input in a if statement inside a function and when I gave it the global keyword and then assigned the variable to another variable in out side the if statement and function i got this error.
port = number
^^^^^^
NameError: name ‘number’ is not defined
Here is my code this code is inside of the if statement and inside the function btw the variable I am having trouble with is the number variable
if open_ports:
question = input('Do you what to open the open ports y/n: ')
if question == 'n':
print('Not opening ports')
elif question != 'y' or 'n':
print('not valid answer')
elif question == 'y':
global number
number = input('Which port to open: ')
for i in range(5000000):
thread = threading.Thread(target=open)
thread.start()
and here a couple line later this is assignment part
port = number
I tried to add the global keyword to the number variable but it will not work. I have no idea what is going on. Also idk if this is helpful but I am using a mac not windows so if that has a difference maybe something went wrong.