-
Notifications
You must be signed in to change notification settings - Fork 3
/
states_helper.py
85 lines (69 loc) · 2.51 KB
/
states_helper.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import json
# Load the JSON data file
with open('data/hindu_temples.json', 'r') as f:
data = json.load(f)
# Function to print temple information
def print_temple_info(temple):
print("==================================================================")
print(f"Name: {temple['name']}")
print(f"State: {temple['state']}")
print("------------------------------------------------------------------")
print(temple['info'])
print("------------------------------------------------------------------")
print(temple['story'])
print("------------------------------------------------------------------")
print(temple['visiting_guide'])
print("------------------------------------------------------------------")
print(temple['architecture'])
print("------------------------------------------------------------------")
print(temple['mention_in_scripture'])
print("==================================================================")
# Function to print all temples information
def print_all_temples_info(data):
for name in data.keys():
temples=data[name]
for temple in temples:
print_temple_info(temple)
# Function to print temples by name
def print_temples_by_state_name(name):
if name in data:
for temple in data[name]:
print_temple_info(temple)
elif name.lower() in data:
for temple in data[name]:
print_temple_info(temple)
else:
print("Sorry, the temple you are looking for was not found.")
print('available options: {}'.format(' , '.join(data.keys())))
# Function to print temple information by name
def print_temple_info_by_name(name):
for name in data.keys():
temples=data[name]
for temple in temples:
if temple['name'].lower() == name.lower():
print_temple_info(temple)
return
print("Sorry, the temple you are looking for was not found.")
for name in data.keys():
temples=data[name]
print('available options for God \'{}\': {}'.format(
name,
', '.join([temple['name'] for temple in temples])
)
)
print("------------------------------------------------------------------")
# Main Function
def main():
# Print all temples information
print("**All Temples Information:**")
print_all_temples_info(data)
# Print temples information by name
name = input("Enter a state name to see temple information: ")
print(f"**Temples of {name}:**")
print_temples_by_state_name(name)
# Print temple information by name
name = input("Enter a temple name to see its information: ")
print(f"**Information about {name}:**")
print_temple_info_by_name(name)
if __name__ == "__main__":
main()