Error when using a single default value in multiselect

Hello,

When I execute the below command,
options = st.multiselect(‘What are your favorite colors’, (‘Green’, ‘Yellow’, ‘Red’, ‘Blue’), (‘Yellow’, 'Red))
st.write(options)

The above code works just fine.

But if I change the default to just a single value say ‘Yellow’
It gives me an error saying every multiselect value must exist in options.

In my code, I am passing a list of values as options and giving the first element of the list as a default value but it is giving me the same error - ‘every multiselect value must exist in options’
Why am I not able to do that?

Is there a workaround that?

1 Like

the default single value should be a list for now

options = st.multiselect(
    "What are your favorite colors",
    ["Green", "Yellow", "Red", "Blue"],
    default=["Yellow"],
)

image

1 Like

I understand now. Thanks for your help.

1 Like