Based on inspiration from answer. I defined a function as below. Looks like its working fine. Please let me know if you find any issue
def isanumber(inp):
try:
val = int(inp)
return True
except ValueError:
try:
val = float(inp)
return True
except ValueError:
return False