streamlit application with a numeric field and submit button, When I press the button, it display the numeric value I put and cleans up the numeric field for a new try
To upload files, please first save the app
import streamlit as st
# Initialize session state for storing submitted numbers
if "submitted_numbers" not in st.session_state:
st.session_state.submitted_numbers = []
# Create a form
with st.form("number_form", clear_on_submit=True):
number = st.number_input("Enter a number", value=0)
submitted = st.form_submit_button("Submit")
if submitted:
st.session_state.submitted_numbers.append(number)
# Display submitted numbers
if st.session_state.submitted_numbers:
st.write("Submitted numbers:")
for num in st.session_state.submitted_numbers:
st.write(num)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?