-
Notifications
You must be signed in to change notification settings - Fork 0
/
assignment_selector.py
53 lines (43 loc) · 1.45 KB
/
assignment_selector.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
51
52
53
prompt = ">"
# a function for user assignment choice
def assign_select(assignments):
count = 1
print('Choose an assignment.')
for num in range(0, len(assignments)):
print(str(count) + ". " + assignments[num]['Name'])
count += 1
# a loop which gets the user's target assignment for input
while True:
try:
target = int(input(prompt))
except ValueError:
print('Enter a number between 1 and ' + str(count))
continue
if target > count:
print('Your choice can\'t be greater than ' + str(count) +'!')
else:
break
# set the target as the chosen assignment dictionary
target = assignments[target-1]
return target
# a function for user transport choice
def trans_select(transports):
count = 1
print('Choose transport.')
for num in range(0, len(transports)):
print(str(count) + ". " + transports[num]['Name'])
count += 1
# a loop which gets the user's target assignment for input
while True:
try:
target = int(input(prompt))
except ValueError:
print('Enter a number between 1 and ' + str(count))
continue
if target > count:
print('Your choice can\'t be greater than ' + str(count) +'!')
else:
break
# set the target as the chosen transport dictionary
target = transports[target-1]
return target