Advertisement
Guest User

Untitled

a guest
Oct 8th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. """
  2. Created on Sat Oct 7 14:38:02 2017
  3.  
  4. @author: Owner
  5. """
  6.  
  7. userName = {}
  8. '''
  9. readLinesFile = open('rLines.txt','wt')
  10. stringTest = 'test'
  11. readLinesFile.write(stringTest)
  12. readLinesFile.close()
  13. inFile = open('rLines.txt','rt')
  14. print(inFile.read())
  15. '''
  16. def testInt(Num):
  17. try:
  18. int(Num)
  19. return True
  20. except:
  21. return False
  22.  
  23. def addUser():
  24. while True:
  25. global userName
  26. newUserFile = open('rLines.txt','rt')
  27. fileVar = newUserFile.readlines()
  28. print (fileVar)
  29. newUserFile.close()
  30. userInpName = input('please name your user')
  31. passWord = input('please make a password')
  32. userName[userInpName] = passWord
  33. print(userName)
  34. userFile = open('rLines.txt','a+')
  35. userFile.write(str(userName))
  36. userFile.close()
  37. return userChoice()
  38.  
  39.  
  40. def findUser(userInp,passInp):
  41. global userName
  42. while True:
  43. print(userInp,passInp,userName)
  44. if userInp in userName.keys():
  45. if userName[userInp][0] == passInp:
  46. print('that is correct')
  47. return userChoice()
  48. else:
  49. print('please return to the menu to select a different option')
  50. return userChoice()
  51. else:
  52. print('this is if userinp isnt in username.keys()')
  53. return userChoice()
  54.  
  55. def userChoice():
  56. userUser = input('please input your choice to \n1.) add a new user\n2.) select an existing user')
  57. if testInt(userUser):
  58. if userUser == '1':
  59. return addUser()
  60. elif userUser == '2':
  61. userName = input('please input your username')
  62. passWord = input('please input your password')
  63. return findUser(userName,passWord)
  64. else:
  65. print('that is not a valid number, please try again')
  66. return userChoice()
  67. else:
  68. print('that is not a number please try again')
  69. return userChoice()
  70.  
  71. userChoice()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement