char=input('enter character:') if '0'<=char<='9': print(char,'is digit') else: print(char,'is not digit') (OR) char=input('enter character:') if 48<=ord(char)<=57: print(char,'is digit') else: print(char,'is not digit') (OR) char=input('enter character:') if char.isdigit(): # isdigit() is a method to find digit or not it returns true and false print(char,'is digit') else: print(char,'is not digit')
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter