Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Extraction solution in Clear category for Reveal the Number by Tinus_Trotyl
def reveal_num(line: str) -> int | float | None:
if not [c for c in line if c in '0123456789']: return None
sign = ''
while line and line[0] not in '.0123456789':
if line[0] in '+-': sign = line[0]
line = line[1:]
line = ''.join(c for c in line if c in '0123456789.')
if '.' in line:
ind = line.index('.')
tail = line[ind + 1:]
decimals = tail.replace('.', '')
return(float(sign + line[:ind] + '.' + decimals))
return int(sign + line)
Jan. 11, 2023
Comments: