Hey Team,
I have two dropdowns and both gets values from user. But when user takes swap actions I want the values in dropdowns to be swapped.
# Create a Streamlit app title
st.title("Language Translator App")
# Create three columns for layout
col1, col2, col3 = st.columns(3)
# Source Language Selection Component
with col1:
source_lang = st.selectbox("Select Source Language", ["English", "French", "Spanish", "German", "Italian"])
# Target Language Selection Component
with col2:
target_lang = st.selectbox("Select Target Language", ["English", "French", "Spanish", "German", "Italian"])
# Swap Language Button
with col3:
if st.button("Swap Languages"):
source_lang, target_lang = target_lang, source_lang
How will this work?