Cody Bable

Generation

generate functionThu, 20 Apr 2023

check if string is integer or float

def check_if_int_or_float(string): try: int(string) return 'integer' except: try: float(string) return 'float' except: return 'string' check_if_int_or_float('3') #returns 'integer'

Questions about programming?Chat with your personal AI assistant