Quantcast
Channel: How do I do a case-insensitive string comparison? - Stack Overflow
Viewing all articles
Browse latest Browse all 16

Answer by zackakshay for How do I do a case-insensitive string comparison?

$
0
0
def search_specificword(key, stng):    key = key.lower()    stng = stng.lower()    flag_present = False    if stng.startswith(key+" "):        flag_present = True    symb = [',','.']    for i in symb:        if stng.find(" "+key+i) != -1:            flag_present = True    if key == stng:        flag_present = True    if stng.endswith(" "+key):        flag_present = True    if stng.find(" "+key+" ") != -1:        flag_present = True    print(flag_present)    return flag_present

Output:search_specificword("Affordable housing", "to the core of affordable outHousing in europe")False

search_specificword("Affordable housing", "to the core of affordable Housing, in europe")True


Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>