st.multiselect now has a max_selections argument (I tested this in Streamlit 1.39.0). Here's a demo.
import streamlit as st
st.title("Multiple Choice Example")
options = st.multiselect(
"Select your options (max 3)",
options=["Option 1", "Option 2", "Option 3", "Option 4"],
max_selections=3,
)
st.write("You selected:", options)