Format_func (function) - Examples Please

Here is a minimal working code to test the options.

import streamlit as st

city_options = { 
    5: "Arizona - Chandler - 5",
    4: "Arizona - Phoenix - 4",
    3: "New Jersey - Newark -3",
    2: "Oregon - Portland - 2",
    1: "Seattle - Washington - 1",
    }   

city_mode = st.sidebar.radio(
    label="Choose a city option:",
    options= (5, 4, 3, 2, 1), 
    format_func=lambda x: city_options.get(x),
    )   

st.write(f'You have chosen {city_options.get(city_mode)}'
        f' with the value {city_mode}.')

Screenshot:

3 Likes