import streamlit as st
sidebar_counter = 9
# this number can vary depending on what is selected by the user
column_list = [col1, col2, col3, col4, col5]
# column_list can vary and be a list that is [col1, col5] and just two items depending on what is selected by the user
#my goal is to assign each col# to each column as follows:
col1, col2, col3, col4 = st.columns(sidebar_counter)
# where sidebar_counter will already include the number of columns selected.
is there any way to dynamically unpack the col1, col2, col3 depending on what is selected?
I have tried the following:
import streamlit as st
column_list = st.columns(sidebar_counter)
However, this does not work as when I call any columns (col1 for example), it is not defined.

You can set the variable in the global dictionary, and then you can call the variable in your script. For example:
Alternatively, you can set the variable in the local dictionary and then call the variable into a function. For example:
However, in my opinion, the best approach is to save the variable in a regular dictionary, and then you can work with that dictionary.