I love using the expression
if 'MICHAEL89' in USERNAMES: ...
where USERNAMES is a list.
USERNAMES
Is there any way to match items with case insensitivity or do I need to use a custom method? Just wondering if there is a need to write extra code for this.
username = 'MICHAEL89' if username.upper() in (name.upper() for name in USERNAMES): ...
Alternatively:
if username.upper() in map(str.upper, USERNAMES): ...
Or, yes, you can make a custom method.
1.4m articles
1.4m replys
5 comments
57.0k users