Advertisement
Guest User

Untitled

a guest
Sep 9th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. customer1,1
  2. customer2,2
  3. customer3,3
  4. customer4,4
  5. customer5,5
  6.  
  7. def strip_split_read_from_file():
  8. bankdetails=[]
  9. with open("bankdetails.txt","r") as f:
  10. for line in f:
  11. line=line.rstrip() #r strip removes the new line character from the right side of the string
  12. split_line=line.split(",")
  13. for field in split_line:
  14. bankdetails.append(field)
  15.  
  16. accessgranted=False
  17. while accessgranted==False:
  18. username=input("username:")
  19. password=input("account no:")
  20.  
  21. for i in bankdetails:
  22. if username==bankdetails[i] and password==bankdetails[i+1]:
  23. accessgranted=True
  24. break
  25. else:
  26. accessgranted=False
  27.  
  28.  
  29. if accessgranted==True:
  30. print("Access Granted")
  31. else:
  32. print("Sorry, wrong credentials")
  33.  
  34. if username==bankdetails[i] and password==bankdetails[i+1]:
  35. TypeError: list indices must be integers, not str
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement