#real password is "password" _KEY = 347 def encrypt(string): secret = hash(string) % 540 return secret chances = 3 def ask_for_password(): secret = encrypt(raw_input("What is your password, please? ")) if secret == _KEY: print "Congratulations, you entered the right password." else: print "Wrong password." global chances chances = chances - 1 if chances > 0: ask_for_password() else: print "You have been locked out of the system." ask_for_password()