hello, please how will I make a user input a list ?
Hi @emmanuel_akpe. Welcome to the Streamlit community!
Can you please provide a bit more context? Are you looking to have the user input a list of string values? Are the values drawn from a finite set (such as with a select box), or are they arbitrary, such as with a text input?
Thanks for the reply
I want the user to input a list of integer values
Are the values arbitrary or from some range?
They are arbitrary please
I think you have two options here,
- If you have a defined set of integers just use multiselect and it should serve the purpose.
- If the user can enter some random numbers you can use regex with text input,
import streamlit as st import re collect_numbers = lambda x : [int(i) for i in re.split("[^0-9]", x) if i != ""] numbers = st.text_input("PLease enter numbers") st.write(collect_numbers(numbers)) fixed_numbers = st.multiselect("Please select numbers", [1, 2, 3, 4, 5]) st.write(fixed_numbers)
The regex code above splits on anything non integers so if the user inputs something like 1,abcd2efg3 it will give you a list of [1, 2, 3]
Hope it helps !