Or How to if-statement in a modified list.
I've been reading StackOverflow for a while (thanks to everyone). I love it. I also seen that you can post a question and answer it yourself. Sorry if I duplicate, but I didn't found this particular answer on StackOverflow.
- How do you verify if a element is in a list but modify it in the same time?
My problem:
myList = ["Foo", "Bar"]
if "foo" in myList:
print "found!"
As I don't know the case of the element in the list I want to compare with lower case list. The obvious but ugly answer would be:
myList = ["Foo", "Bar"]
lowerList = []
for item in myList:
lowerList.append(item.lower())
if "foo" in lowerList:
print "found!"
Can I do it better ?