# Format\_func (function) - Examples Please

**URL:** <https://discuss.streamlit.io/t/format-func-function-examples-please/11295>\
**Category:** Using Streamlit\
**Tags:** selectbox, multiselect, radio-button\
**Created:** [March 28, 2021, 6:48am UTC](https://discuss.streamlit.io/t/format-func-function-examples-please/11295 "2021-03-28T06:48:33Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![hiankun](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/hiankun/32/8535_2.png) [@hiankun](https://discuss.streamlit.io/u/hiankun)\
**Post date:** [June 14, 2021, 7:40am UTC](https://discuss.streamlit.io/t/format-func-function-examples-please/11295/5 "2021-06-14T07:40:06Z")

</div>

Here is a minimal working code to test the options.

```auto
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:

 ![2021-06-14-153854_810x181_scrot](https://global.discourse-cdn.com/streamlit/original/2X/e/eca61043d2628fdb62ada8aa03c2ee070f428009.png)

---

_[View the full topic](https://discuss.streamlit.io/t/format-func-function-examples-please/11295)._
