0

I'm new in programming. I'm currently programming on a knowledge base (just for me). I had a problem with the core, which then looks at what you have written and returns the labels. He always says "Tkinter, command" no matter what you tell him. Here is the code:

#Core#
def search(text):
    text=str(text)
    if "tkinter" or "Tkinter" in text:
        if "command" or "Command" or "Command-Befehl" or "command-Befehl" or "command-befehl" or "Command Befehl" or "command Befehl" or "Command befehl" or "command befehl" in text:
            search="Tkinter, command"
            return search
        if "lambda" or "Lambda" in text:
            return "Tkinter, lambda"
    if "bug" or "Bug" in text:
        return "bug"
    if "test" in text:
        return "test"
print(search("bug"))

(It's an module)

I tried all possible values but it always returned the same thing. I've also looked on various websites but haven't found anything.

lt2020
  • 9
  • 2
  • 1
    Does this answer your question? [Why does "a == x or y or z" always evaluate to True? How can I compare "a" to all of those?](https://stackoverflow.com/questions/20002503/why-does-a-x-or-y-or-z-always-evaluate-to-true-how-can-i-compare-a-to-al) – Tom Karzes May 07 '23 at 08:48
  • 1
    This is a common beginner's mistake. You need to remember that Python is not English, it's a programming language with very rigid syntax. Specifically, `"a" or "b" in x` groups as `"a" or ("b" in x)`, and is always true. Change it to `"a" in x or "b" in x"`. See the duplicate answer for more info. – Tom Karzes May 07 '23 at 08:49
  • This is slightly irrelevant to your original question, but just a quick tip. To shorten your code down, you could convert "text" to "text.lower()" to then compare inputs without needing to duplicate words with a capital letter. – Chris T-Pot May 07 '23 at 10:58

0 Answers0