Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- def fav_num():
- file_name = 'favorite_number.json'
- try:
- with open(file_name) as f:
- fav = json.load(f)
- except FileNotFoundError:
- fav = input("Whats you num?")
- with open(file_name, 'w') as f:
- json.dump(fav, f)
- print("We'll remember your num")
- else:
- print("Yay,we remembered it: ", fav)
- fav_num()
Add Comment
Please, Sign In to add comment