Guest User

Untitled

a guest
Oct 23rd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. class Player(object):
  2.  
  3. def __init__(self, username_str="-", password_str=""):
  4. while (not validated(password_str)):
  5. self.password_str=input("Password is invalid. Please try again:")
  6. self.username=username_str
  7.  
  8. def change_password(self,old_password):
  9. MAX_ATTEMPT=3
  10. num_of_fails=0
  11. while(old_password!=self.password_str):
  12. num_of_fails+=1
  13. if(num_of_fails<MAX_ATTEMPT):
  14. old_password=input("Thej passwword entered is invalid. Please try again.
  15. (You have "+str(MAX_ATTEMPT-num_of_fails)+" attempts reamining)")
  16. else:
  17. print("Incorrect password entered too many times. Your account is temporarily locked.")
  18. break
  19.  
  20. if(num_of_fails<MAX_ATTEMPT):
  21. new_password=input("please enter a new password.")
  22.  
  23. while(not validated(new_password)):
  24. new_password=input("New password is invalid. Please try again")
  25.  
  26. self.password_str=new_password
  27. print("Password has been successfully changed!")
Add Comment
Please, Sign In to add comment