I have dict like:
{ id1 : Name1, id2: Name2 }
I add to selectbox array of all Names. I also need the correspond id to the selected name.
Can i in some why to keep this relation in selectbox? And when i chose the name i can get correct ID.
ofc i can to write custom function that can find id, but it looks tahat not always works for same names.

Hi @iGero, welcome to the forum :wave:

You can use format_func to your advantage here

import streamlit as st

options = {
    "id1": "name1",
    "id2": "name2",
    "id3": "name1",

option = st.selectbox("selectbox 2", list(options.items()), 0 , format_func=lambda o: o[1])

1 Like

Thans. it works!