How to store values at each interaction during the repetition of a structure - Python

Asked

Viewed 36 times

-3

lista= ["2,55","3,4","3,83","5,1","6,8"]


for i in range(len(lista)):


    lista[i] = lista[i] 


    #PREEENCHER VALOR

    navegador.find_element_by_xpath('...').send_keys(lista[i])
    time.sleep(3)
    #obter valor #
    valor = navegador.find_element_by_xpath('...')
    valor = valor.text[:-3].replace(',', '.')

I would like to store each value generated for each interaction made.

  • Welcome to Stackoverflow in English, you may want to take a tour: pt.stackoverflow.com/tour or take a look at Help Center: pt.stackoverflow.com/tour and see how to ask questions in a way that can be answered quickly, try to report what you have tried and post your code, hardly anyone will do the job for you. Since you do not have an idea of how to do what you need, initially it is better to do a survey and then if you have some difficulty in programming you can ask again here.

1 answer

-1

If I understand the question correctly, you should create a new list to store the generated values. Create a new empty list value variable.

Example:

valores = []
...
valor = valor.text[:-3].replace(',', '.')
valores.append(valor)

Unfortunately, I can’t understand your code exactly, the variables are not within the scope of this code, I don’t know where it comes from usinas, for example.

  • Thanks for the reply

Browser other questions tagged

You are not signed in. Login or sign up in order to post.