Skip to content

Commit 3d91528

Browse files
authored
Create check_input.py
1 parent 38ca7d9 commit 3d91528

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎check_input.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def get_user_input(start,end):
2+
3+
testcase = False
4+
while testcase == False:
5+
try:
6+
userInput = int(input("Enter Your choice: "))
7+
if userInput > 6 or userInput < 1:
8+
print("Please try again.")
9+
testcase = False
10+
else:
11+
return userInput
12+
13+
except ValueError:
14+
print("Please try again.")
15+
16+
17+
x = get_user_input(1,6)
18+
print(x)
19+
20+
21+
###Asks user to enter something, ie. a number option from a menu.
22+
###While type != interger, and not in the given range,
23+
###Program gives error message and asks for new input.

0 commit comments

Comments
 (0)