How to use multiple columns in forms so that the input is side by side instead of below each

For anyone that is looking for the answer to my own question above, here is how I fixed it:

with st.form(key='columns_in_form'):
    c1, c2, c3, c4 = st.columns(4)
    with c1:
        initialInvestment = st.text_input("Starting capital",value=500)
    with c2:
        monthlyContribution = st.text_input("Monthly contribution (Optional)",value=100)
    with c3:
        annualRate = st.text_input("Annual increase rate in percentage",value="15")
    with c4:
        investingTimeYears = st.text_input("Duration in years:",value=10)

    submitButton = st.form_submit_button(label = 'Calculate')

This did the trick, one form with four inputs in four different columns:

4 Likes