Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. f=open("UsernamePasswords.txt","r")#opens text file
  2. usernamePasswords=[]#creates new list
  3. for line in f:#for each line in the textfile
  4. line=line.strip("\n")#strip the /n in the line
  5. usernamePasswords.append(line.split())#append the line and break between the space
  6.  
  7. username=input("Enter your username: ")#asks user for username
  8. found=False#found is false
  9. uPlength=len(usernamePasswords)#length of list
  10. for i in range(uPlength):#for each index in the range of the lists length
  11. if username == usernamePasswords[i][0]:#if the username is equal to the one in the list
  12. print("Password =",usernamePasswords[i][1])#prints out the password
  13. found=True#found is true
  14. if found == False:#if its not found
  15. print("Username not found")#prints out that the username was not found
  16. f.close()#closes the text file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement