summaryrefslogtreecommitdiff
path: root/search_past_papers.py
blob: a0532265f9fe702d232c251ef54e8c949fbe6146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import json

subject_code = input("Subject code: ")
dic = json.load(open(f"{subject_code}.json"))
search_str = input("Word or words to be searched: ").lower()
flag = True
print("\nThe following are files that contain such string: ")

for year in dic.keys():
    for file in dic[year].keys():
        for page in dic[year][file].keys():
            if search_str in dic[year][file][page]:
                print(file, f"[Page {page}]")
                flag = False

if flag:
    print("No file found")