Advertisement
Guest User

Untitled

a guest
Mar 14th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.99 KB | None | 0 0
  1. #! /usr/bin/python3
  2.  
  3. user = ''
  4. passW = ''
  5.  
  6. def login():
  7. correctUser = False
  8. correctPass = False
  9. loggedIn = False
  10. attempts = 0
  11. print('You are now at the login screen. Enter a username or type "exit" to leave.')
  12. while correctUser == False:
  13. user = input()
  14. if user == 'admin':
  15. print('Access granted.')
  16. correctUser = True
  17. print('Enter the password.')
  18. elif user == '':
  19. print('Enter a username.')
  20. elif user == 'exit':
  21. print('Exiting.')
  22. exit()
  23. else:
  24. print('"' + user + '" is not a valid username. Try again.')
  25. while correctPass == False:
  26. passW = input()
  27. if passW == 'admin':
  28. print('Access granted.')
  29. correctPass = True
  30. loggedIn = True
  31. console()
  32. elif passW == '':
  33. print('Enter a password.')
  34. else:
  35. attempts = attempts + 1
  36. if attempts == 5:
  37. print('Too many attempts.')
  38. exit()
  39. else:
  40. print('Access denied. Try again.')
  41.  
  42. def console():
  43. loggedIn = True
  44. msg = 'You have 3 messages. Type "read" to view, or "back" to go back.'
  45. print('Welcome to the admin console.')
  46. while loggedIn == True:
  47. print('What would you like to do?')
  48. print('You can try "help," "view messages," or "logout."')
  49. choice = input()
  50. if choice == 'help':
  51. continue
  52. elif choice == 'view messages':
  53. print(msg)
  54. choice = input()
  55. if choice == 'read':
  56. msg()
  57. elif choice == 'back':
  58. continue
  59. else:
  60. stupid = True
  61. while stupid == True:
  62. print('You need to either choose "read" or "back."')
  63. choice = input()
  64. if choice == 'read':
  65. msg()
  66. elif choice == 'back':
  67. stupid = False
  68. else:
  69. continue
  70. elif choice == 'logout':
  71. loggedIn = False
  72. login()
  73.  
  74. def msg():
  75. viewingMessage = True
  76. msg1 = 'Hi, this is Bob. I was wondering if you finished those documents. Thanks.'
  77. msg2 = 'Hello, this is Rachel. Do we still have our meeting scheduled for Thursday?'
  78. msg3 = 'Howdy, this is Randy from engineering. We have a couple of things to look at in the server room and we will need your help. What time are you available?'
  79. print('You have 3 messages.')
  80. print('view 1')
  81. print('view 2')
  82. print('view 3')
  83. print('')
  84. print('What would you like to do?')
  85. while viewingMessage == True:
  86. choice = input()
  87. if choice == 'help':
  88. print('Your options are one of the messages, "view" to see the list again, or "back."')
  89. elif choice == 'view 1':
  90. print(msg1)
  91. print('')
  92. elif choice == 'view 2':
  93. print(msg2)
  94. print('')
  95. elif choice == 'view 3':
  96. print(msg2)
  97. print('')
  98. elif choice == 'view':
  99. print('You have 3 messages.')
  100. print('view 1')
  101. print('view 2')
  102. print('view 3')
  103. elif choice == 'back':
  104. stupid = True
  105. while stupid == True:
  106. print('Go back to the admin console? (yes/no)')
  107. choice2 = input()
  108. if choice2 == 'yes':
  109. stupid = False
  110. viewingMessage = False
  111. console()
  112. elif choice2 == 'no':
  113. stupid = False
  114. print('What would you like to do?')
  115. else:
  116. print('You must type "yes" or "no."')
  117. continue
  118. else:
  119. print('Are you stuck? Try typing "help."')
  120.  
  121. login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement