12 lines
256 B
Python
12 lines
256 B
Python
|
def try_float(value: str) -> int | float | str:
|
||
|
try:
|
||
|
return float(value)
|
||
|
except:
|
||
|
pass
|
||
|
try:
|
||
|
return int(value)
|
||
|
except:
|
||
|
pass
|
||
|
raise ValueError(f"Could not convert {value} to float or int")
|
||
|
# return value
|