How to take two inputs as parameters

Hi, I am creating a hotel recommendation system that accepts two user inputs(destination, the purpose of the trip). For this, I want to take two user inputs and then execute the code but the code starts executing as I enter the first user input. Can anyone suggest?

val1 = st.text_input('Val 1')
val2 = st.text_input('Val 2')
if val1 and val2 and st.button('Go'):
    st.write(f'Got all inputs: {[val1, val2]}')
    # do something...

Anything more complicated than this would be better implemented as a simple web form in a Streamlit component (see the Streamlit React component samples and

1 Like