How to pass 5 user imputs to a model in phyton?

When i try, all the w1,w2,w3,w4, are the same, what i m doing wrong?

st.subheader("YLD")
w1 = st.text_area("")
#st.write(w1)

st.subheader("MST")
w2 = st.text_area("")
#st.write(w2)

st.subheader("STLP")
w3 = st.text_area("")
#st.write(w3)

st.subheader("RTLP")
w4 = st.text_area("")
#st.write(w4)

st.subheader("Button")
w5 = st.button("Click me")
st.write(w5)

if w5:
    st.write(w1,w3,w2,w4)

Hi @jpcofano

Your code is very close! The one thing missing is that all widgets should have different labels, and in your case they’re all labeled with an empty string "".

So to make it work you’d do this:

w1 = st.text_area("YLD")
#st.write(w1)

w2 = st.text_area("MST")
#st.write(w2)

w3 = st.text_area("STLP")
#st.write(w3)

w4 = st.text_area("RTLP")
#st.write(w4)

w5 = st.button("Click me")
st.write(w5)

if w5:
    st.write(w1,w3,w2,w4)

(I also removed the subheaders since the labels I added have the same text as the old subheaders, so it would just be repetitive)

The next version of Streamlit will actually show a warning when widgets have the same label, so at least this solution won’t be as hard to discover.

2 Likes

@thiago thanks!!! and sorry for the newbie question!
I misunderstood the function of st.subheader