forked from DataGlacier/VC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
174c88c
commit ba879ae
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#https: // github.com / DataGlacier / VC.git | ||
import json, os | ||
os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
|
||
# User can add name and favourite sport in response.json | ||
# default sport Cricket will be added incase user does not provide fav sport | ||
|
||
|
||
def load_json(): | ||
with open('../response.json') as json_obj: | ||
response = json.load(json_obj) | ||
return response | ||
|
||
|
||
response = load_json() | ||
|
||
def write_json(data,filename = '../response.json'): | ||
with open(filename,'w') as file: | ||
json.dump(data,file,indent=0) | ||
|
||
|
||
def call_sport(): | ||
name = input("Please add your name: ") | ||
sport = input("Please add your favourite sports name: ") | ||
if (sport == ""): | ||
sport = 'Cricket' | ||
if (name): | ||
response[name] = sport | ||
write_json(response) | ||
|
||
|
||
if __name__ == "__main__": | ||
call_sport() | ||
|
||
call_sport() |