Is there a way to use lower() or casefold() at the "in" operator like
if 'string' in these_list.lower()
I know this is not possible, but there should be a way to achieve this in an elegant way
You can use like:
if val.lower() in this_list:
but not the way you try. lower must be applied to individual item, therefore list doesn't qualify.
I've the problem on the list or dictionary side which I read from a file as csv, josn, etc
As Larz60+ told you, you can't call lower
on a list (or a dictionary) for that matter. It doesn't make sense does it? Turning something to lowercase only makes sense if that something is a string. A list of strings is not a string! If you want to do that to all the items in a list, for example, either write a for
loop, or a list comprehension to produce a new list.