-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.py
24 lines (22 loc) · 845 Bytes
/
input.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
import os
# Allows you to prompt the user for a filename (string input) and returns the path providing the file exists
def user_input_filename(prompt):
value = ""
while value == "":
print("\n%s: " % prompt)
value = input()
if os.path.isfile('./input/' + str(value)):
return './input/' + str(value)
else:
print("Invalid file name! (ensure the photo is in the input folder)")
value = ''
# Allows you to prompt the user for an integer input between a lower and upper bound
def user_input_integer(prompt, lower_b, upper_b):
value = -1
while value == -1:
print("\n%s between %d - %d: " % (prompt, lower_b, upper_b))
value = int(input())
if value >= lower_b and value <= upper_b:
return value
else:
value = -1