-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecon_flashcards.py
50 lines (45 loc) · 1.52 KB
/
econ_flashcards.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
def main():
"""
main loops through an econ.txt file generated from econ_looper.py and starts a flashcard quiz.
"""
with open("econ.txt", "r") as f:
lines = f.readlines()
flashcards = {}
question = ""
answer = ""
isQuestion = False
isAnswer = False
start = False
startChapter = 2
endChapter = 3
for line in lines:
if line.startswith(f"Chapter {startChapter}"):
start = True
if (not start):
continue
if line.startswith(f"Chapter {endChapter}"):
break
if (line.startswith("Diff:")):
isAnswer = False
flashcards[question] = answer
isQuestion = False
question = ""
answer = ""
continue
if (line.startswith("Answer:") or isAnswer):
isQuestion = False
isAnswer = True
answer += line
if ((line[0].isdigit() and line[1] == ")") or (line[0].isdigit() and line[1].isdigit() and line[2] == ")") or isQuestion):
isQuestion = True
question += line
# print(flashcards.items())
for question, answer in flashcards.items():
print(f"Question: {question}")
ans = input("Your answer: ")
if (ans == answer[-1]):
continue
else:
print(f"Actual {answer}")
if __name__ == "__main__":
main()