PY
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
"""
Input a string and the program will tell you if:
1. Input is a hexedemical value
2. Input is made only of letters
3. Input is made only of numbers, or it is a decimal number
Please feel free for some suggestions of what else program could check about input. I like to work with codes like that :)
"""
import re
inp = input()
if re.match(r"^(#)?(0x)?([0-9A-Fa-f]){2,}$", inp):
if re.match(r"^[0-9]*$", inp):
print("Hexedemical value and only numbers also.")
elif re.match(r"^[A-Fa-f]*$", inp):
print("Hexedemical value and only letters also.")
else:
print("Hexedemical value.")
elif re.match(r"^[A-Za-z]+$", inp):
print("Only letters.")
elif re.match(r"^[0-9]+$", inp) or re.match(r"^([0-9])+\.([0-9])+$", inp):
print("Only numbers or a decimal number.")
else:
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run