Hi guys I would like to develop a streamlit app which needs languages to be selected as input so for example English and it’s value en I have Python dictionary of all the languages I want to put them in selectbox so that when I choose a language it’s value abbreviation is the output of my selection please help me
My dictionary looks like this {“English”:”en”, “Arabic”:”ar”}
So please help me to design this selection box with options as languages and the out is value in the dictionary
Thanks in advance
This may be help
import streamlit as st
my_dict = {'English':'en', 'Arabic':'ar'}
my_select = st.selectbox('Choose one:', options=list(my_dict.keys()))
if my_select:
my_value = my_dict[my_select]
I feel as though you conditional statement is lacking other arguments
It’s like this
import streamlit as st
my_dict = {'Choose one': '', 'English':'en', 'Arabic':'ar'}
my_select = st.selectbox('Choose one:', options=list(my_dict.keys()), label_visibility='collapsed')
if my_select and my_select != 'Choose one':
my_value = my_dict[my_select]
st.info(f'Your select: {my_value}')