-
Notifications
You must be signed in to change notification settings - Fork 0
/
task13.py
43 lines (37 loc) · 955 Bytes
/
task13.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
def ValidateString(inStr):
validity = 0
if len(inStr) == 2:
validity += 1
else:
validity = -100
if inStr[0].upper() == "A" or "B" or "C":
validity += 1
else:
validity = -100
try:
if int(inStr[1]) in range(1,4):
validity += 1
else:
validity = -100
except:
validty = -100
out1 = 0
out2 = 0
if validity == 3:
# Would rather use a switch statement here
if inStr[0].upper() == "A":
out1 = 1
if inStr[0].upper() == "B":
out1 = 2
if inStr[0].upper() == "C":
out1 = 3
out2 = int(inStr[1])
return (out1, out2)
else:
return (False)
# Test Cases
print(ValidateString("A2")) # 1,2
print(ValidateString("BEELZEBUB")) # False
print(ValidateString("C3")) # 3,3
print(ValidateString("C4")) # False
print(ValidateString("A0")) # False