Im Anonymous wrote:Thanks a lot this really helped the only thing is, I don't really understand the code.
- Code: Select all
#import the 'getpass' module which makes the getpass.getpass() function
#available for you to use in your following code
#loop will continue until break statement is reached i.e. if pass1 is the same as pass2
#prompts for a password, this module hides what the user types http://pymotw.com/2/getpass/
pass1 = getpass.getpass('Enter Password: ')
#again, a prompt with hidden user entry
pass2 = getpass.getpass('Enter Password again: ')
#if the user has typed the same thing twice (from above i.e. this if statement equals True)
if pass1 == pass2:
#print to the screen 'passwords match'
#break out from the loop, passwords match, all is good (else statement below is ignored)
#if pass1 does not equal pass2 (i.e. the if statement above was equal to False)
#print to the screen 'passwords did not match'
print('passwords did not match')
#final line within the loop, else statement has been executed,
#passwords did not match, stays in loop, goes back to 'Enter Password: '
I am a Python beginner myself and I can appreciate searching google does not always help you with the specific example you are stuck on. I feel lmgtfy is not helpful in this case. Maybe this will get you on your way.