I want to make two buttons that when a user clicks one button (A) then a question (a) is displayed; when the user clicks the other button (B) then another question (b) is displayed and the previous question (a) disappears.
Code is below
if "AAA" not in st.session_state: st.session_state.AAA = False if "BBB" not in st.session_state: st.session_state.BBB = False A = st.button("A") B = st.button("B") if A or st.session_state.AAA: st.session_state.AAA = True st.session_state.BBB = False st.radio('a',('a','a','a')) if B or st.session_state.BBB: st.session_state.BBB = True st.session_state.AAA = False st.radio('b', ('b','b'))
My code works when I switch from session state AAA to BBB, but not the reverse way.
For more details, when question a is displayed, I clicked button B and question b appears but question a is still there.