Hi all,
I try to use a session state to remove an item from a list (i want in the second step to use this new list, to select another item from it).
My minimal code is here (I have commented out the 2nd select box, since it throws the error before)
import streamlit as st
if 'teams' not in st.session_state:
st.session_state['teams'] = ['GER', 'FRA', 'NED', 'USA', 'UAE', 'ISR', 'THA', 'COL']
teamA_name = st.sidebar.selectbox("Team A", options=st.session_state['teams'])
teamA_name_sub = st.sidebar.button('Submit Team A',key="Team A key")
if teamA_name_sub:
st.session_state['teams'].remove(teamA_name)
st.header(teamA_name)
#teamB_name = st.sidebar.selectbox('Team B', options=st.session_state['teams'])
#teamB_name_sub = st.sidebar.button('Submit Team B', key="Team B key" )
st.write(st.session_state['teams'])
The error occurs after I press the submit button and says:
File "/Users/behnk001/Library/Python/3.8/lib/python/site-packages/streamlit/elements/selectbox.py", line 120, in serialize_select_box
return index_(opt, v)
File "/Users/behnk001/Library/Python/3.8/lib/python/site-packages/streamlit/util.py", line 129, in index_
raise ValueError("{} is not in iterable".format(str(x)))
ValueError: NED is not in iterable
So it somehow does not like the remove function.
Any ideas about what I do wrong?
Thanks a lot