How to get variable value inputted by user in one tab and carry it over to second tab

Dear experts
I have a scenario, where I have 2 tabs. First tab is to get some input from user, say β€œa”, β€œb” etc. and then when user switch over to second tab, using those 2 inputs second tab will show some value based on β€œa” abd β€œb” value (for example you may consider as sum of a+b is to be shown in tab 2, actually it;s more than a sum). Pls suggest how to achieve this, as for me while switching over to second tab, values from tab 1 are refreshed automatically which I don’t want. I want to go back to tab 1 and see the same values as user entered earlier.


import streamlit as st

tab1, tab2 = st.tabs(["Operand", "Sum"])

with tab1:
   st.subheader('Input values')
   value1 = st.number_input('a', step=1)
   value2 = st.number_input('b', step=1)

with tab2:
   st.write(value1 + value2)


1 Like

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