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.
More Related Contents:
- case-insensitive list sorting, without lowercasing the result?
- Why is it string.join(list) instead of list.join(string)?
- Remove empty strings from a list of strings
- Converting a string representation of a list into an actual list object [duplicate]
- What exactly does the .join() method do?
- Join a list of items with different types as string in Python
- How slow is Python’s string concatenation vs. str.join?
- Loop “Forgets” to Remove Some Items [duplicate]
- Find and replace string values in list
- Alphabet range in Python
- How do I split a string into a list of characters?
- Splitting on last delimiter in Python string?
- Python split string into multiple string [duplicate]
- Confused about __str__ on list in Python [duplicate]
- Joining pairs of elements of a list [duplicate]
- How do I convert a list into a string with spaces in Python?
- Finding a substring within a list in Python [duplicate]
- Perform a string operation for every element in a Python list
- Convert string to list. Python [string.split() acting weird]
- Change a string of integers separated by spaces to a list of int
- How to create a list with the characters of a string? [duplicate]
- Python: How to check a string for substrings from a list? [duplicate]
- Convert a columns of string to list in pandas
- How to apply __str__ function when printing a list of objects in Python [duplicate]
- How to return all list elements of a given length?
- Adding a string to a list using augmented assignment
- Extracting words from a string, removing punctuation and returning a list with separated words
- Deleting consonants from a string in Python
- How can I convert string values from a dictionary, into int/float datatypes?
- How does str(list) work?