Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- username_file = 'username.json'
- try:
- with open(username_file) as file:
- print('Are you ' + json.load(file) + '?')
- check_username = input('Press Y if yes or N if no: ')
- if check_username == 'Y':
- print('Welcome back, ' + json.load(file))
- if check_username == 'N':
- username = input('Input your name: ')
- with open(username_file, 'w') as file:
- json.dump(username, file)
- print('See you next time!')
- except FileNotFoundError:
- username = input('Input your name: ')
- with open(username_file, 'w') as file:
- json.dump(username, file)
- print('See you next time!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement