Reputation: 27614
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?
Upvotes: 0
Views: 162
Reputation: 8989
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"
Upvotes: 3