st.multiselect
displays a multiselect widget.
Here's how to use st.write:
import streamlit as st
st.header('st.multiselect')
options = st.multiselect(
'What are your favorite colors',
['Green', 'Yellow', 'Red', 'Blue'],
['Yellow', 'Red'])
st.write('You selected:', options)
The very first thing to do when creating a Streamlit app is to start by importing the streamlit
library as st
like so:
import streamlit as st
This is followed by creating a header text for the app:
st.header('st.multiselect')
Next, we're going to use the st.multiselect
widget to accept input where users will be able to select one or more colors of there choice.
options = st.multiselect(
'What are your favorite colors',
['Green', 'Yellow', 'Red', 'Blue'],
['Yellow', 'Red'])
Finally, we'll write out the selected colors:
st.write('You selected:', options)