You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository has a logger included. This also provides an example of how to Logger works. This logger may or may not be useful for all the projects.
Validate the user input and ensure the user input a number between the minimum and maximum values. Will keep trying if the user inputs an invalid character or a number out of the range.
8
+
:param prompt – the prompt to ask the user in the user input
9
+
:param min – the minimum value – defaults to 0
10
+
:param max – the maximum value – defaults to infinity
11
+
:return int of choice
12
+
"""
13
+
try:
14
+
val=int(input(prompt))
15
+
if(val>maxorval<min):
16
+
raiseTypeError
17
+
returnval
18
+
exceptTypeError:
19
+
"""
20
+
out of range failure caught
21
+
"""
22
+
print(f"Value not between {min} and {max}")
23
+
returnvalidate(prompt, min, max)
24
+
exceptValueError:
25
+
"""
26
+
Invalid type caught
27
+
"""
28
+
print("Value inputted was not a number! Try again!")
0 commit comments