How to use output variables from one button in another button?

Something like this should work:

if 'result' not in st.session_state:
    st.session_state.result = None

if start:
    try:
        # performs operation
        # final_res generated
    finally:
        st.session_state.result = final_res

if stop:
   st.write(st.session_state.result)
1 Like