So, I've been coding for a Python 'computer software', one where you basically have a log-in username and password that can be edited. I tried to add a feature that allows you to 'remove' the password, (but is more like skipping it) but it won't work. Here is the code for the skipping procedure:
def Access1():
print("Input first name")
print("")
answer = raw_input()
if(answer.lower() == username and PasswordSkip == True):
print("")
print("Access granted")
List1()
if(answer.lower() == username and PasswordSkip == False):
print("")
print("Access granted")
Access2()
*Note that Access2()
is the function where a password is needed to continue, and List1()
is the main menu of the system.
Here is where the boolean is set to True
:
def PasswordRemove():
print("")
print("Are you sure you want to remove your password, <yes> or <no>?")
print("")
key = raw_input()
if(key.lower() == "yes"):
PasswordSkip = True
print("")
print("Ok, your password has been removed.")
print("")
List1()
elif(key.lower() == "no"):
DetailsChange()
else:
DetailsChange()
And here is how I define and globalise PasswordSkip
:
PasswordSkip = False
def Startup():
global PasswordSkip
(the function goes on longer, but has no involvement in the boolean.)
If you need any more infor ation on my code, I'm able to give it to you.
So, when I run my code, it overlooks the if statement about the boolean. If the boolean is True
, it should go to a different function. However, it skips the statement because it brings up Access2()
(the password function).
Answers aren't urgently needed, but thanks.