-
Notifications
You must be signed in to change notification settings - Fork 0
/
News.py
34 lines (27 loc) · 893 Bytes
/
News.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json
final = {}
def add_month(month):
print("Month {} created successfully!".format(month))
news_dict = {}
news = input("Add news: ")
while news != "done":
news_dict.update(add_news(news))
news = input("Add News: ")
with open('news.json', 'w') as f:
json.dump({month: news_dict}, f)
def add_news(news):
print("News created successfully!")
element_dict = {}
element = input("Add concerned element: ")
while element != "done":
change = float(input("Add Change: "))
element_dict.update({element: change})
element = input("Add concerned element: ")
return {news: element_dict}
month = input('Add month: ')
while month != 'done':
add_month(month)
month = input("Add month: ")
with open('news.json', 'r') as f:
months = json.load(f)
print(months)