-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNEW_MakeFlashdeck.py
More file actions
55 lines (43 loc) · 1.49 KB
/
Copy pathNEW_MakeFlashdeck.py
File metadata and controls
55 lines (43 loc) · 1.49 KB
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
from CommaManagement import *
import os
import random
import string
def makeFlashdeck():
while True:
title = str(input("Flashdeck Name [press ENTER to exit]: "))
if title == '':
return None
elif title.strip() == '':
print('flashdeck title must NOT be blank!')
else:
break
fTitle = 'flashdecks/' + title + '.txt'
flashdeck = []
with open(fTitle, 'w') as f:
while True:
question = str(input(f"question (type in [X] to close flashdeck): "))
if question == 'x' or question == 'X':
if len(flashdeck) < 5:
print('you must have at least 5 flashcards in your flashdeck!')
continue
else:
break
elif question.strip() == '':
print('question must NOT be blank!')
continue
while True:
answer = str(input('answer: '))
if answer.strip() == '':
print('answer must NOT be blank!')
continue
else:
break
question.strip()
answer.strip()
flashdeck.append(commaconverter((question, answer)))
print(f"flashcard \'{question}\' addded!")
for l in flashdeck:
f.write(','.join(l) + ',\n')
print(f'{title} added!')
if __name__ == "__main__":
makeFlashdeck()