how to use find command in python for case insensitive search

convert the original string and the substring to lowercase using the lower() method before performing the search. As a result, the find() method returns the correct index even though the case of the substring doesn’t match the original string.

if text.lower().find('flyer') >= 0:
            height = 1024
            width = 512
        elif text.lower().find('poster') >= 0:
            height = 512
            width = 1024 



Leave a Reply