Answer the question
In order to leave comments, you need to log in
How to loop through two arrays and find matches (and then change the color of the word)?
There are two arrays of words (left_text and right_text). It is necessary to sort out the first for matches in the second. And if there is a match, perform certain actions.
def compare():
if win.left_textBrowser.toPlainText() != '' and win.right_textBrowser.toPlainText() != '':
for x in left_text:
print(str(x) + ' check')
if x in right_text:
print(str(x) + ' ok')
win.left_textBrowser.setText(win.left_textBrowser.toPlainText() + green_text + str(x) + green_text_end)
else:
print(str(x) + ' no')
win.right_textBrowser.setText(win.right_textBrowser.toPlainText() + str(x))
green_text = '<span style=\" font-size:8pt; font-weight:600; color:#00ff00;\" >'
green_text_end = '</span>'
Answer the question
In order to leave comments, you need to log in
did not quite understand what you are doing, but a list of matching elements of two lists can be found like this:
then, perhaps like this:
for x in result:
win.left_textBrowser.setText(win.left_textBrowser.toPlainText() + green_text + str(x) + green_text_end)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question