Select a default value


I am trying to use the function. I want to have a None Value for the return, as long as the user hasn’t choosen his answer.
Though, it’s not working for now, and i get the following API error:

**StreamlitAPIException**: Selectbox Value has invalid type: NoneType
File "C:\Users\hdandria\Documents\Gitlab\maintenance-predictive-explicabilite\Anomaly detection with Isolation", line 147, in <module>
    option = st.selectbox(

Steps to reproduce

The code that I’m using is the one of the documentation:

import streamlit as st

genre =
    "What's your favorite movie genre",
    [":rainbow[Comedy]", "***Drama***", "Documentary :movie_camera:"],

st.write("You selected:", genre)

Note: The functions behaves properly, as long as I don’t set index as None.
Do you have any idea on the origin of this problem ?

Hey @Henri_d_ANDRIA,

Thanks for sharing this question!

I’m having trouble reproducing this error. What version of Streamlit are you running?

This is what I see when I run your code:

The error is caused by some other code that you didn’t post.

Thank you for you answers.
I was running streamlit 1.26 when encoutering this error. I updated my version to 1.27, and the error disappeared.