How to create dynamic columns

i am trying to display returned records inside columns where the screen is displayed into 3 or 4 columns how to do it ?

once i run the code it display the below error:

IndexError: list index out of range

Traceback:

File "f:\aienv\lib\site-packages\streamlit\scriptrunner\script_runner.py", line 443, in _run_script
    exec(code, module.__dict__)File "F:\AIenv\streamlit\TEC_APPS\fit_in_out_leb.py", line 1520, in <module>
    main()File "F:\AIenv\streamlit\TEC_APPS\fit_in_out_leb.py", line 590, in main
    with c[cnt]:

code:

def card(ID,name,nickname,mother_name,bd,v1,v2,v3,v4):

    return f'''

            <div class="card text-center" style="width: 18rem;">

                <div class="card-body">

                    <h5 class="card-title">ID: {ID}</h5>

                    <h6 class="card-subtitle mb-2 text-muted" style =" display:{v1};">name: {name}  </h6>

                    <p class="card-text"style =" display:{v2};">nickname: {nickname }</p>

                    <p class="card-text"style =" display:{v3};">date of birth: {bd}</p>

                    <p class="card-text"style =" display:{v4};">mother name: {mother_name}</p>
                </div>
            </div>
        '''

rec = int(df_result_search.shape[0]/2)
st.write("{} Records ".format(str(df_result_search.shape[0])))
                    
c = st.columns(max(1, rec))
dv = 'inherit'
cnt=0
for index ,row in df_result_search.iterrows():
        v1 = dv if row[1] is not None else 'none'
        v2 = dv if row[2] is not None else 'none'
        v3 = dv if row[3] is not None else 'none'
        v4 = dv if row[4] is not None else 'none'
                
        with c[cnt]:
                st.markdown(card(
                            row[0],    
                            row[1],
                            row[2],
                            row[3],
                            row[4]
                            v1,v2,v3,v4),unsafe_allow_html=True)
                  cnt+=1