- #1
katie_3011
- 5
- 0
Homework Statement
Hi. So I'm stuck on a few things right now, but the main one is that Python is telling me that one of my variables is not defined. I have stressed over this for about an hour now trying everything to change it, and I cannot seem to find issue.
Homework Equations
The Attempt at a Solution
My program is large, but shrinking it down to the relevant information:
def main ():
masterlist = getData("facepalm")
#Where getData is another function and facepalm is a textfile
def getData (filename):
textfile = open ("facepalm", "r")
user1 = [...]
#insert list of data from the textfile in order to separate the users from each other
user2 = [...]
masterlist = [[user1], [user2]]
textfile.close ()
#So this whole function works and gets the data
#Then the program proceeds to a login function where the user needs to enter the correct username and password
def usernameAndPasswordInput ():
username = input ("Enter your username: ")
password = input ("Enter your password: ")
for elmt in masterlist:
if elmt [0]==username:
if elmt [1]==password:
return masterlist
else:
...
So, the issue that I'm having is in the for loop which is where python tells me that the global name 'masterlist' is not defined.
Also, if you need me to send you my whole program via email, that's fine. I just didn't want to post all of it due to copy and paste programming.
Any help you can give me on this would be great, thanks.
Katie