I’d like to format values in my st.number_input
with the format
arg. My step is 0.5, and I would like every number to have only one trailing 0, like such
1.0, 1.5, 2.0 …
Here is what I have tried:
st.number_input("Prop Line", value=5.5, step=0.5, format="%g")
This results in the following:
1, 1.5, 2, 2.5 … (no trailing 0 for the whole numbers)
I’ve found a way to give one trailing 0 to any number:
"{0:.1f}".format(0)
0.0
But streamlit doesn’t like "{0:.1f}"
as a parameter for format
:
st.number_input("Prop Line", value=5.5, step=0.5, format="0:.1f")
StreamlitAPIException: Format string for st.number_input contains invalid characters: 0:.1f