I'm trying to find a match value from a keyword using python. My values are stored in a list (my_list
) and in the below example I'm trying to find the word 'Webcam'. I only want to return the word if it is fully matched.
Using item.find works but only if the case matches (i.e. upper and lower case must be correct). But I want to return the item regardless of the case, However, I do not wish to match all instances of the string like 'Webcamnew' so using the any() method won't work I think. Does anyone know how to do this..?
my_list = ['webcam', 'home', 'Space', 'Maybe later', 'Webcamnew']
for item in my_list:
if item.find("Webcam") != -1:
print item