Консоль сообщает, что «продолжить» и «прервать» не входят в цикл.
print(f"Prime Number Checker")
while True:
# Inputs
integer = input("\nEnter an integer to test: ")
# Processes
number = int(integer)
is_prime = True
i = 0
for i in range(2, number-1):
if number % i == 0:
is_prime = False
break
if is_prime:
print(f"{number} is a prime number")
else:
print(f"{number} is a composite number because it is divisible to {i}")
break
else:
print(f"Invalid integer value! Try again")
continue
option = input(f"Do you want to test another integer (y/n): ")
if option == "n":
break
# Outputs
print(f"Bye!")
Я пытался выполнить, но ничего не помогло.
В консоли должно быть указано следующее:
Enter an integer to test: 25
25 is a composite number because it is divisible by 5
Do you want to test another integer (y/n): y
Подробнее здесь: https://stackoverflow.com/questions/785 ... eak-not-in
Что заставляет этот код выводить «Недоступно» и «продолжать и прерывать цикл»? ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как мне решить бесконечный цикл, чтобы он мог продолжать просить пользователя ввести число?
Anonymous » » в форуме C++ - 0 Ответы
- 18 Просмотры
-
Последнее сообщение Anonymous
-