文字列のリストがあります
["oranges", "POTATOES", "Pencils", "PAper"]
paper
大文字と小文字を区別せずに、リストにが含まれているかどうかを確認したい。次のコードスニペットが出力されるようにしますfound
。私のリストには、英語のアルファベット(大文字と小文字)のみで構成される単純な文字列のみが含まれています。
item = 'paper'
stuff = ["oranges", "POTATOES", "Pencils", "PAper"]
if item in stuff:
print "found"
else:
print "Not found"
#How do I get the method to print "found"?
明確化:
私のリストは実際にはリストのリストであり、私のロジックは次の構成を使用しています。
if not any ( item in x for x in stuff):
print "Not found"
else:
print "found"