-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlilypad.py
32 lines (22 loc) · 838 Bytes
/
lilypad.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
def dictionary_selector(dictionary: dict, error_message: str = "\n\nTry again"):
def check_length(index: int, length: int = len(dictionary)):
return -1 < index < length
dictionary_string = [
f"[{i}] {key}"
for i, key in
enumerate(dictionary.keys())
]
i = 'g'
while type(i) != int or not check_length(i):
print(*dictionary_string, sep="\n")
i = input("Pick: ")
try:
i = int(i)
if not check_length(i): print('\n\nTry again')
except ValueError: print('\n\nTry again')
return i
def yes_or_no(msg: str) -> bool: return input(f'{msg} [Y/n]').lower() != 'n'
def no_or_yes(msg: str) -> bool: return input(f'{msg} [y/N]').lower() == 'y'
def fix_names(name):
name = name.replace('\t', ' ')
return name