How to ensure that Multiselect can never be empty?

st.sidebar.header(“Please Filter Here:”)
city = st.sidebar.multiselect(
“Select the City:”,
options=df[“City”].unique(),
default=df[“City”][0]

I have the above multiselect but it allows user to cross out all selections, so the multiselect has none selected , which then gives error. So I want a way to restrict the user not to be able to completely clear out the multiselect - atleast one value must be selected at all times.

How about give city a default value if city return None?

1 Like