How to create multiple selectbox with different key?

how to create multiple select box inside a for loop using different key .

When i tried to create it crash and display the below error:

But when i try to use st.text_input it works and display it.

raise ValueError(โ€œ{} is not in iterableโ€.format(str(x)))

code:

for i , old_val in enumerate(range(5))):
         old_val = st.selectbox(" ",old_values,key=i)

You could modify the following code for your use:

import streamlit as st

old_values = [โ€œAโ€, โ€œBโ€, โ€œCโ€, โ€œDโ€, โ€œEโ€]
for i in range(len(old_values)):
old_val = st.selectbox(" โ€œ,old_values,key=f"MyKey{i}โ€)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.