-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.py
More file actions
49 lines (44 loc) · 1.13 KB
/
Copy pathinterface.py
File metadata and controls
49 lines (44 loc) · 1.13 KB
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
import sys
def choose_working_mode():
"""
Function has input with common checks
:return: (string) function returns each string input
"""
attempt = 0
while attempt < 5:
try:
mode = input("""
Press
P - play
S - safe
B - both
"""
)
if mode in "PpSsBb":
break
else:
print("incorrect mode")
except EOFError:
if attempt < 4:
print("EOFError")
attempt += 1
else:
print("we ran into System crash")
sys.exit(-1)
return mode
def correct_int_input(messege):
"""
Function has input with common checks
:param messege: (string) what should user input
:return: (int) returns input, if it can be converted into int
"""
while True:
value = input(messege)
if str.isnumeric(value):
return_value = int(value)
if return_value >= 0:
break
print("please write positive number")
else:
print("please write a number")
return return_value