Python fails to detect String Match Found

Below is my code for comparing string for Exact Match found in python.

    for word in jdbc_trgt.split(','):
        global comp
        comp=word.strip();
        print "GloBAL:" + comp
        fiIn = open('list.txt').readlines()
        for lines in fiIn:
            print "line1s:" + lines
            print comp + " == " + lines
            if comp == lines:
                print "MATCH:" + comp

Can you tell me why is print "MATCH:" + comp not getting printed despite the strings Matching ?
Note: I am looking for an EXACT match Found scenario.

if comp == lines.strip():

Does not work.

It is is now Matching everything despite them being very different.

Output:

Note: I need exact Match.

---------- Post updated at 12:29 PM ---------- Previous update was at 10:12 AM ----------

I even tried

if str(comp) == str(lines):

But still no Luck. Can someone help please ?

What is your input data?

I am split a string into words using a delimiter [check here: Issue Spliting String in Python ] and storing it in variable

variable while the other words are read from a text file for comparison.

So i am split a string into words and then checking if that word is present in the text file or not.

if comp == lines.strip():
1 Like

This also does not work.

I get the below error.

Problem invoking WLST - Traceback (innermost last):
  (no code object) at line 0
  File "/web/jdbc.py", line 70
                     if comp == lines.strip():
                     ^
SyntaxError: invalid syntax

---------- Post updated at 02:38 PM ---------- Previous update was at 01:36 PM ----------

This worked !! Thank you !!

---------- Post updated at 02:39 PM ---------- Previous update was at 02:38 PM ----------

Resolved