I am looking for a method analogous to if "x" in variable:
that is case insensitive and light-weight to implement.
I have tried some of the implementations here but they don't really fit well for my usage: Case insensitive 'in' - Python
What I would like to make the below code case insensitive:
description = "SHORTEST"
if "Short" in description:
direction = "Short"
Preferably without having to convert the string to e.g. lowercase. Or if I have to convert it, I would like to keep description
in its original state – even if it is mixed uppercase and lowercase.
For my usage, it is good that this method is non-discriminating by identifying "Short"
in "Shorter"
or "Shortest"
.