forked from baconwaifu/PyVCDS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.py
More file actions
24 lines (23 loc) · 683 Bytes
/
menu.py
File metadata and controls
24 lines (23 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def selector(lst):
while True:
try:
print("Do What?")
for i in range(len(lst)):
print("{}: {}".format(i,lst[i]))
iput = input("> ")
ret = int(iput)
if ret < len(lst):
return ret
except ValueError:
print("Enter the integer value of the selected option")
def dselector(dct, header="Do What?"):
while True:
try:
print(header)
for k,v in dct.items():
print("{}: {}".format(k,v))
ret = input("> ")
if ret in dct or int(ret) in dct: #some of these use integer keys instead of strings
return ret
except ValueError:
print("Enter the integer value of the selected option")