From the site I catch the variable name_elem_site . I can not properly make a check if the current word is not equal to the last entry in the list, then add the word . Those. comes from the site

Word1, Word3, Word1, Word2, WordN ...

I get in the log, how many fun word from ms to sec, so many times and write:

Word1, Word1, Word1, Word2, Word2, Word2, ....

And because of this, I can not then calculate how many times the word was displayed. Because Word1 seemed only once for 20 seconds, for example, it’s written in my logs that 20 values ​​were entered.

name_elem_site = text_element_by_class_name(driver, "texttexttext") currentList = [] currentWord = currentList.append(str(name_elem_site)) if name_elem_site: for word in currentList: if word == currentWord: continue currentWord = word currentList.append(word) log.write("%s\n" % word) log.flush() 

1 answer 1

Check the last item

 if currentList[-1] != word currentList.append(word) 

Check for entry into the list at all

 if word not in currentList: currentList.append(word)