UnboundLocalError: cannot access local variable 'select_space' where it is not associated with a value

Hello people, can you help me?

I have a function that runs a FOR looking for information from the bank, after this FOR I have a st.select_box where if the user selects option X, I will do an update, if I select option Y I will not do anything. But what happens is that the page reloads and does not bring anything and the prompt appears the topic title message. Here’s the function:

**verificador=pgadmin_connect.consultar_db_by_telefone(input_name) **


** if input_button_submit:**
** if verificador !=None:**
** elect_space=[‘Selecione’,‘Escolher’,‘Nada’]*

  •        for item in pgadmin_connect.consultar_db_by_telefone(input_name):*
    
  •            st.write('O nome {} já existe. Favor confirmar o telefone:'.format(input_name))*
    
  •            col1, col2, col3=st.columns((1,1.1,1.2))*
    
  •            col1.write(item.nome)*
    
  •            col2.write(item.telefone)*
    
  •            #select_space=col3.empty()*
    
  •            select_space=st.selectbox(label='O que deseja fazer?',options=select_space)*
    
  •            *
    
  •        if select_space=='Escolher':*
    
  •                #Chamar o atualizar e passar o id antigo*
    
  •                pgadmin_connect.editar_db_recorrente(item.id)*
    
  •                st.write('Editado com sucesso! {}'.format(item.telefone))*
    
  •             *
    
  •                #st.experimental_rerun()*
    
  •            *
          elif select_space=='Nada':**
    

** vs.nome=input_name**
** #vs.sobrenome=input_lastname**
** vs.sexo=input_sexo**
** vs.idade=input_age**
** if input_recorrente == ‘Sim’:**
** vs.recorrente=‘Visitante novo’**
** else:**
** vs.recorrente=‘Recorrente’**
** vs.observacao=input_observacao**
** vs.endereco=input_adress**
** vs.data=datetime.date.today()**


** if input_phone !=(27): **
** vs.telefone=input_phone**
** else:**
** input_phone=None**
** vs.telefone=input_phone**
** pgadmin_connect.inserir_db(vs)**

verificador=pgadmin_connect.consultar_db_by_telefone(input_name)

if input_button_submit:
    if verificador !=None:
        select_space=['Selecione','Escolher','Nada']
        for item in pgadmin_connect.consultar_db_by_telefone(input_name):
            st.write('O nome {} já existe. Favor confirmar o telefone:'.format(input_name))
            col1, col2, col3=st.columns((1,1.1,1.2))
            col1.write(item.nome)
            col2.write(item.telefone)
            #select_space=col3.empty()
            select_space=st.selectbox(label='O que deseja fazer?',options=select_space)
            
        if select_space=='Escolher':
                #Chamar o atualizar e passar o id antigo
                pgadmin_connect.editar_db_recorrente(item.id)
                st.write('Editado com sucesso! {}'.format(item.telefone))
             
                #st.experimental_rerun()
            
        elif select_space=='Nada':
            
                    vs.nome=input_name
                    #vs.sobrenome=input_lastname
                    vs.sexo=input_sexo
                    vs.idade=input_age
                    if input_recorrente == 'Sim':
                        vs.recorrente='Visitante novo'
                    else:
                        vs.recorrente='Recorrente'
                    vs.observacao=input_observacao
                    vs.endereco=input_adress
                    vs.data=datetime.date.today()
                    
                    if input_phone !=(27):    
                        vs.telefone=input_phone
                    else:
                        input_phone=None
                        vs.telefone=input_phone
                    pgadmin_connect.inserir_db(vs)