Alright, I'm only here 'cause its my last resort and troubleshooting did jackshit. I'm coding a password generator in python and it says "ask" is not defined pls help as im new to programming.
Code below:
""" Simple password generator
By: Anon104 """
#imports
import random
#varibles
while ask == 'n':
question=input("Generate password? Press any key... ")
password= random.randrange(0,10000000)
ask=input("Do you want to quit? y/n ")
print(password)
if ask=='y':
exit
>>380911
well, your problem is that "ask" is not defined
helpful, right?
if you look at the error message python prints out, it says the issue is specifically on line 5. that makes sense; it's the first time the word "ask" appears in the program, so that's the kind of place you'd get an undefined error
on line 5, you're telling the computer to start doing some stuff while some variable called "ask" has value 'n'
and the computer looks for a variable called "ask" and can't find it, so it can't check what value it has, so it complains to you because you fucked up and told it to check the value of something that didn't exist
if you want to define a variable, you have to write something like this (an assignment expression):
name = value
and then all of the code after that (at the same indentation level or deeper) will have access to a variable called "name"
tl;dr add a line before the while loop that says "ask = 'n'" so that python knows, before the while loop starts, that there is a variable called "ask" that has value 'n'.