Answer the question
In order to leave comments, you need to log in
How to loop my super python code?
Hello.
how can i loop it? please help;(
so that every time when the user answers n / N it would return to the then line
and so on in a circle until the answer is yes.
I can’t understand at all, I looked at the examples, but I don’t catch the logic.
1 number = input( "Type your number here:")
2 print("your number is:"+ str(number))
3 yournumber = input("Right number? (Y/N): ")
4 then = input("Type your number again : ")
Answer the question
In order to leave comments, you need to log in
#Бесконечный цикл. Цикл while работает если он True
while True:
#Вводим данные
number = input("Type your number here:")
#Выводим
print("Your number is:" + str(number))
#Просим ввода
yournumber = input("Right number? (Y/N):")
#Если пользователь ввёл y или Y волшебное слово break останавливает цикл. Если if не сработал, цикл повторяется снова
if yournumber == "y" or yournumber == "Y":
break
Write an infinite loop, the exit condition from which will be:
yournumber == 'Y'
You can exit the loop using break .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question