How to store multiple input values if st.text_input is mentioned twice?

Problem: I am facing the issue in storing multiple input values

Error: DuplicateWidgetID: There are multiple identical st.text_input widgets with key='<module 'random' from '/usr/lib/python3.8/random.py'>'.

To fix this, please make sure that the key argument is unique for each st.text_input you create.

Code:

ans = st.text_input('please provide your answer:- ')
            if ans == que_dict[0]['Answer']:      
                score += 1
                st.write('its correct')
                st.write()
                type_of_question ='Level_2'                   
            else:
                type_of_question ='Level_1'
                st.write('incorrect :(')
                st.write()
            easy_que_list.remove(que_to_ask_id)
            count +=1
        

ans = st.text_input('please provide your answer:- ')
            if ans == que_dict[0]['Answer']:      
                score += 1
                st.write('its correct')
                st.write()
                type_of_question ='Level_3'                   
            else:
                type_of_question ='Level_'2'
                st.write('incorrect :(')
                st.write()
            easy_que_list.remove(que_to_ask_id)
            count +=1

Hi @Sai95,

Thanks for posting!

You can either change the name of one of the text input widgets so that they don’t have the same name, or you can add a unique key. Check out our documentation on st.text_input here.

e.g.

ans = st.text_input('please provide your answer:- ', key='first_question')

Caroline :balloon: