How to access values returned from last execution?

Hey everyone. Thanks Streamlit team for this awesome library.

So I’m trying to run the following block of code…

frozen_context = None

if __name__ == "__main__":
    question = st.text_input('PREGUNTA', '')

    if question:
        freeze = st.checkbox('FREEZE')
        if not freeze:
            query = get_pronoun(question)
            context, url = get_wiki_paragraph(query)
            frozen_context = context
        else:
            context = frozen_context
        answer = get_question(question, context)
        start, end, text = answer['start'], answer['end'], answer['answer']
        pattern = context[start:end]
        new_context = context.replace(pattern, '**' + pattern + '**')

        st.empty().markdown(f'RESPUESTA: **{text}**')
        st.empty().markdown(new_context, unsafe_allow_html=True)
        st.empty().markdown(f'REFERENCIA: {url}')

I want to save the variable ‘context’ in ‘freezed context’ so I can access that last variable everytime I check the box. Problem is that Streamlit runs top to bottom and resets everything (variable ‘frozen_context’ goes back to None). How can I do this? Thanks in advance!