Cody Bable

Generation

generate functionThu, 20 Apr 2023

check if string is a number

def is_number(s): try: float(s) return True except ValueError: pass try: import unicodedata unicodedata.numeric(s) return True except (TypeError, ValueError): pass return False is_number("1.23")

Questions about programming?Chat with your personal AI assistant