Guest User

Untitled

a guest
May 23rd, 2018
1,967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. username = raw_input("Username: ")
  2. password = raw_input("Password: ")
  3.  
  4. login = open("login.txt", "r")
  5.  
  6. for line in login:
  7. if line.split(":")[0] == username and line.split(":")[1] == password:
  8. print("It Works!")
  9. else:
  10. print("Failed")
  11.  
  12. admin:password
  13. nimda:drowssap
  14.  
  15. # I added the 'with' clause so that the file is opened fresh each run
  16. # (for debugging - the file cursor is iterated each time a line is read)
  17. with open("login.txt", "r") as login:
  18. lines = login.readlines()
  19.  
  20. for line in lines:
  21. if line.strip().split(":")[0] == username and line.strip().split(":")[1] == password:
  22. print("It Works!")
  23. else:
  24. print("Failed")
Add Comment
Please, Sign In to add comment