[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Help

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 2
Thread images: 1

File: download.png (3KB, 387x130px) Image search: [Google]
download.png
3KB, 387x130px
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'.
Thread posts: 2
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.