Select same item several times in multiselect within a form

Having the following code, how can I select the same item several times given in st.multiselect ?

import streamlit as st

options = ["A","B","C"]
st.multiselect("Select the items",options)

I’d appreciate any help!

If you want to just use the multislect widget, then you need to repeat the items within the options list up to the maximum number of times you want to allow its selection. If you want to allow selecting an option up to 10 times, it would need to be included in the options list 10 times.

For example, this allows each option to be selection up to two times.

import streamlit as st

result = st.multiselect('Choose',['A','A','B','B','C','C'])
st.write(result)

If that is not to your liking, you could always use the multiselect to get the unique list of selections and then iterate through the unique selections to create number inputs to get a multiplicity for each. Or you could ditch the multiselect entirely and go straight to getting multiplicity for each of your options (defaulting everything to 0 for not selected).

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.