The rest of the program cant see the password variable

The program crashed because, for some reason, the program couldn't find a variable called password. But that's a little odd, because you define it in the set password () function:

def set_password():

password="C8H10N4O2

set_password () ^ This ¿ode ¿alls for the password to be set def send_to_twitter(msg):

password_manager = urllib.request.HTTPPasswordMgr() password_manager.add_password("Twitter API",

This code uses the password... but for some reason, it can t | see ^

'http://twitter.com/statuses", "starbuzzceo", password)

So what happened? Why can't the send to twitter () function see the password variable that was created in the set password() function?

Programming languages record variables using a section of memory called the stack. It works like a notepad. For example, when the user is asked if she wants to send a price immediately, her answer is recorded against the price now variable:

Was this article helpful?

0 0

Post a comment