#🔒 help with case insensitivity

23 messages · Page 1 of 1 (latest)

inner dirge
#

hi, just look for help with case insensitivity. im working with 2 list and using a for loop to cycle through one to check if usernames are in another. thank you all

spare fossilBOT
#

@inner dirge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

lavish brook
#

!d str.lower

spare fossilBOT
#

str.lower()```
Return a copy of the string with all the cased characters [[4]](https://docs.python.org/3/library/stdtypes.html#id15) converted to lowercase.

The lowercasing algorithm used is [described in section 3.13 ‘Default Case Folding’ of the Unicode Standard](https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-3/#G33992).
lavish brook
#

you need to compare lower string to lower string

#

also you can't compare list == str

#

that will never be true

#

that's what you are doing in current_users == users.lower()

#

it may help if you name your variables with proper plurality

#
for user in new_users: ...
#

the iteration variable only represents one user at a given moment

inner dirge
#

so i need to compare the strings from the lists rather than the lists themselves? sorry is just confusing

vital ridge
spice nova
inner dirge
#

this has appeared to work although not sure if its still case sensitive

lavish brook
inner dirge
#

i also changed the currents_users to lowercase

lavish brook
#

that would work then

inner dirge
#

thank you. my outputs were lowercase too. but i changed the

#

removed*, user =users.lower() and placed user.lower after the if and elif statement

spice nova
# inner dirge removed*, user =users.lower() and placed user.lower after the if and elif statem...

Like if user.lower() in current_users ? That's fine. But note that this: user = user.lower() is also fine in that it doesn't change the content of the new_users list. It just makes a new string in lowercase and points user at that new string. Previously it was pointing at the string from new_users.

Also, you don't need the elif ... not in test - if you get there, you already know it's not in because the in test above failed. So you can just use else.

spare fossilBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.