0

i am just trying to find out a word noone in a string whether it is in lower case or upper case or mixed.

This is the code:

post= "hi noone bro"
a = "noone"
print(a in post)

If I replace noone with noOne it shows False. How can I fix it?

1
  • Just convert both to lower case before checking. Commented May 18, 2021 at 4:25

2 Answers 2

2

You can apply .lower() or .upper() to strings when finding matches, effectively eliminating casing.

So this would return true: "noone".lower() == "noOne".lower()

Sign up to request clarification or add additional context in comments.

Comments

0

You need to convert both to either lowercase or uppercase using .lower() or .upper() or can do something like this.

post= "hi noone bro"
a = "noOne"
print(a.casefold() in post.casefold())

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.