python - Case insensitive 'in' - Stack Overflow

PHOTO EMBED

Tue Aug 02 2022 01:17:27 GMT+0000 (Coordinated Universal Time)

Saved by @rckt #python

if 'MICHAEL89'.casefold() in (name.casefold() for name in USERNAMES):
Or:

if 'MICHAEL89'.casefold() in map(str.casefold, USERNAMES):
As per the docs:

Casefolding is similar to lowercasing but more aggressive because it is intended to remove all case distinctions in a string. For example, the German lowercase letter 'ß' is equivalent to "ss". Since it is already lowercase, lower() would do nothing to 'ß'; casefold() converts it to "ss".
content_copyCOPY

https://stackoverflow.com/questions/3627784/case-insensitive-in