Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- username = raw_input("Username: ")
- password = raw_input("Password: ")
- login = open("login.txt", "r")
- for line in login:
- if line.split(":")[0] == username and line.split(":")[1] == password:
- print("It Works!")
- else:
- print("Failed")
- admin:password
- nimda:drowssap
- # I added the 'with' clause so that the file is opened fresh each run
- # (for debugging - the file cursor is iterated each time a line is read)
- with open("login.txt", "r") as login:
- lines = login.readlines()
- for line in lines:
- if line.strip().split(":")[0] == username and line.strip().split(":")[1] == password:
- print("It Works!")
- else:
- print("Failed")
Add Comment
Please, Sign In to add comment