Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import json
  2.  
  3. username_file = 'username.json'
  4. try:
  5. with open(username_file) as file:
  6. print('Are you ' + json.load(file) + '?')
  7. check_username = input('Press Y if yes or N if no: ')
  8. if check_username == 'Y':
  9. print('Welcome back, ' + json.load(file))
  10. if check_username == 'N':
  11. username = input('Input your name: ')
  12. with open(username_file, 'w') as file:
  13. json.dump(username, file)
  14. print('See you next time!')
  15. except FileNotFoundError:
  16. username = input('Input your name: ')
  17. with open(username_file, 'w') as file:
  18. json.dump(username, file)
  19. print('See you next time!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement