Capturing outputs from arbitrary number of widgets in form

I am new to Streamlit so forgive me if I am missing something obvious.

I have created an app that reads in a list of items and uses a loop to display each one next to a radio widget in a single form. The user then makes selections for the radio buttons (think “buy”/ “sell”/“hold”) and submits the form. I want to capture each widget’s state at form submission, but I am trying to figure out a way to identify which widget is which. I can give them each a unique “key” but I don’t know how to use this to access the state at submission time.

Here is a minimal example:

import streamlit as st

stocks = # some arbitrary-length list of stock symbols

with st.form("stock_picker"):
    for stock_symbol in stocks:
        col1, col2 = st.beta_columns(2)
        with col1:
            decision = st.radio("Decision", ["Buy", "Sell", "Hold"], key=stock_symbol)
        with col2:
            st.write(stock_symbol)

    submitted = st.form_submit_button("Submit")
    if submitted:
        # How to capture each `decision` here?

I think I figured it out myself. I believe I can collect the widgets in a dict and their current state will be available later. Let me know if there are any obvious problems with this approach.

import streamlit as st

stocks = # some arbitrary-length list of stock symbols

widget_dict = {}
with st.form("stock_picker"):
    for stock_symbol in stocks:
        col1, col2 = st.beta_columns(2)
        with col1:
            decision = st.radio("Decision", ["Buy", "Sell", "Hold"], key=stock_symbol)
            widget_dict[stock_symbol] = decision
        with col2:
            st.write(stock_symbol)

    submitted = st.form_submit_button("Submit")
    if submitted:
        for symbol, widget_state in widget_dict.items():
            # do something with each widget state