0

Is this simple string_line to find keyword exist or not.

Keyword exist but still it's go inside if condition.

Keyword exist but in mixed case why can not capture mixed case lowercase or uppercase.

string_line = '<p>this is real crm and for real CRM amd and Read Crm.</p>\r\n'
keyword = 'Real CRM'

if keyword not in string_line:
    print "Keyword Not Found____"
else:
    print "Keyword Found____"

How to check keyword exist in same case or mixed case then return keyword found in string?

1 Answer 1

3

Change the cases to be the same:

string_line = '<p>this is real crm and for real CRM amd and Read Crm.</p>\r\n'
keyword = 'Real CRM'

if keyword.lower() in string_line.lower():
    print "Keyword found"
else:
    print "Keyword not found"
Sign up to request clarification or add additional context in comments.

2 Comments

is this return if keyword present in capitalized REAL CRM in a string ?
This is completely case insensitive, so it will always match if the string contains the keyword. The string and keyword can both be any or mixed case. Is that what you wanted?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.