St.number_input: conditional formatting

Hello,

I was wondering if someone could help? Bit stuck on this one, might be easy for others but…

I’d like to format to 2 or 4 decimal float places.
100.00 or 0.1000

step = 100.0 if a_value >= 1 else 0.1
mat = ‘%.2f’ if a_value >= 1 else ‘%.4f’

a_value would be the current value inputted by the user.
150 or 0.1500

st.number_input(label=‘Number Input’,
value=value,
step=step,
format=mat)

I can’t get st.number_input to format correctly.

format won’t do lamda i.e. format = lamda x: x >= 1 or x if x >=1 else y

Kind regards
Gedzy

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.