hex check

Tim Rowe tim at remove_if_not_spam.digitig.co.uk
Wed Jul 16 06:16:39 EDT 2003


On Wed, 16 Jul 2003 10:39:33 +0300, Ruslan Spivak <alienoid at is.lg.ua>
wrote:

>Hello.
>
>Does anybody have a hint how to check if input hex number is in correct 
>hex format?

could always try:

num = raw_input("Enter hex number"):
try:
    int(num, 16)
    print "Yes, that was hex!"
except:
    print "Doesn't look like hex to me!"

I'm sure someone else here can do better.




More information about the Python-list mailing list