choice = "" while choice != "Да" or "Нет": choice = input("Могу предложить подсказку(введите Да или Нет): ") if choice == "Да": points = 5
The problem is that the cycle is endless. Do not really understand why?
The condition of your cycle is equivalent to (choice != "Да") or "Нет"
. This condition is always true (if the condition in brackets is false, then "No" is interpreted as true, because it is a non-empty string), so the loop is infinite.
You need a condition of choice != "Да" and choice != "Нет"
or choice not in {"Да", "Нет"}
.
choice not in ("Да", "Нет")
brackets (tuple) or at worst square (list)? - VisioNFirstly, the condition of the cycle is not written correctly. And it is not clear: if the choice is "No", then what?
choice = "" while choice != "Да" or choice != "Нет": choice = input("Могу предложить подсказку(введите Да или Нет): ") if choice == "Да": print("points = 5") points = 5 elif choice == "Нет": print("Выходим из цикла, не взяв подсказку!")
Source: https://ru.stackoverflow.com/questions/414667/
All Articles