Removing an item from multi select

I am trying to delete objects from a list by choosing them via a multiselect widget. However, after the app reruns I get the error: streamlit.errors.StreamlitAPIException: Every Multiselect default value must exist in options

if st.button("Fill") or "options" not in st.session_state:
	st.session_state.options=["a","b","c"]

def submit():
	for item in st.session_state.selected:
		st.session_state.options.remove(item)

form=st.form("My form")
form.multiselect("Select", st.session_state.options, key="selected")
form.form_submit_button("Submit", on_click=submit)

I tried to add the line
st.session_state.selected=[]
to the submit function so that the multiselect-box is cleared and does not reference deleted items, but it did not solve the issue.

The error message looks like this:

Exception in thread ScriptRunner.scriptThread:
Traceback (most recent call last):
  File "/Users/arc/opt/anaconda3/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/Users/arc/opt/anaconda3/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/arc/opt/anaconda3/lib/python3.8/site-packages/streamlit/script_runner.py", line 182, in _process_request_queue
    widget_states = self._session_state.as_widget_states()
  File "/Users/arc/opt/anaconda3/lib/python3.8/site-packages/streamlit/state/session_state.py", line 447, in as_widget_states
    return self._new_widget_state.as_widget_states()
  File "/Users/arc/opt/anaconda3/lib/python3.8/site-packages/streamlit/state/session_state.py", line 198, in as_widget_states
    states = [
  File "/Users/arc/opt/anaconda3/lib/python3.8/site-packages/streamlit/state/session_state.py", line 201, in <listcomp>
    if self.get_serialized(widget_id)
  File "/Users/arc/opt/anaconda3/lib/python3.8/site-packages/streamlit/state/session_state.py", line 179, in get_serialized
    serialized = metadata.serializer(item.value)
  File "/Users/arc/opt/anaconda3/lib/python3.8/site-packages/streamlit/elements/multiselect.py", line 139, in serialize_multiselect
    return _check_and_convert_to_indices(opt, value)
  File "/Users/arc/opt/anaconda3/lib/python3.8/site-packages/streamlit/elements/multiselect.py", line 118, in _check_and_convert_to_indices
    raise StreamlitAPIException(
streamlit.errors.StreamlitAPIException: Every Multiselect default value must exist in options

Thanks for any help in advance! :slight_smile: