I have code that generates random math examples. The program asks the user what character he wants in the example (+, -, /, *) . And further the condition on whether he wrote a mat at all. operator, and not any "йсмйСЙ234ВЙ2Ф" . "йсмйСЙ234ВЙ2Ф" I tested, and noticed: when I write exactly mat. operator, he from the test displays, as if I entered not what is written in the condition. Here is the code snippet:
want = input("Выберите знак действия для вашего примера (+, -, /, *): ") if want != "+" or "-" or "/" or "*": print("!!! | Вы должны ввести ЗНАК действия!") else:
oroperator returns True if there is True on the left or right. Therefore, when you writeчтототам or "-", the whole expression is automatically considered True (because the string to the right is True) and the condition is triggered. - andreymal