St.number_input and on_changed options


I want to display the new value entered in the number_input widget in the function ‘val_changed’ using the ‘on_changed’ option. Using the following code, the value is the previous one.

import streamlit as st
def val_changed():

number = st.number_input('Add a number', on_change=val_changed)

How to do that? thank you.

You can use “IF” just as the following code.

if number:

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