how to create a while true loop? [duplicate]












-2
















This question already has an answer here:




  • Asking the user for input until they give a valid response

    17 answers




let me start off by saying, that i am a BEGINNER to coding. i use python 3.4.GUI.



so i've got this code:



register = input("have you registered an 
account?")
if register == "yes":
print("you may proceed to log in")
if register == "no":
print("please, create an account")
else:
print("that is not a valid answer")


how to i create a while true loop on this so that if the user enters anything other than "yes" or "no", they get taken back to the start?
thanks!










share|improve this question













marked as duplicate by Thierry Lathuille, Jean-François Fabre python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 14:24


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 2





    Wrap the whole thing in while True:.

    – erip
    Nov 22 '18 at 14:19











  • use elif instead of multiple ifs

    – mad_
    Nov 22 '18 at 14:20











  • Looks like this has been answered before. stackoverflow.com/questions/50498557/…

    – Michael Buchok
    Nov 22 '18 at 14:22
















-2
















This question already has an answer here:




  • Asking the user for input until they give a valid response

    17 answers




let me start off by saying, that i am a BEGINNER to coding. i use python 3.4.GUI.



so i've got this code:



register = input("have you registered an 
account?")
if register == "yes":
print("you may proceed to log in")
if register == "no":
print("please, create an account")
else:
print("that is not a valid answer")


how to i create a while true loop on this so that if the user enters anything other than "yes" or "no", they get taken back to the start?
thanks!










share|improve this question













marked as duplicate by Thierry Lathuille, Jean-François Fabre python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 14:24


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 2





    Wrap the whole thing in while True:.

    – erip
    Nov 22 '18 at 14:19











  • use elif instead of multiple ifs

    – mad_
    Nov 22 '18 at 14:20











  • Looks like this has been answered before. stackoverflow.com/questions/50498557/…

    – Michael Buchok
    Nov 22 '18 at 14:22














-2












-2








-2









This question already has an answer here:




  • Asking the user for input until they give a valid response

    17 answers




let me start off by saying, that i am a BEGINNER to coding. i use python 3.4.GUI.



so i've got this code:



register = input("have you registered an 
account?")
if register == "yes":
print("you may proceed to log in")
if register == "no":
print("please, create an account")
else:
print("that is not a valid answer")


how to i create a while true loop on this so that if the user enters anything other than "yes" or "no", they get taken back to the start?
thanks!










share|improve this question















This question already has an answer here:




  • Asking the user for input until they give a valid response

    17 answers




let me start off by saying, that i am a BEGINNER to coding. i use python 3.4.GUI.



so i've got this code:



register = input("have you registered an 
account?")
if register == "yes":
print("you may proceed to log in")
if register == "no":
print("please, create an account")
else:
print("that is not a valid answer")


how to i create a while true loop on this so that if the user enters anything other than "yes" or "no", they get taken back to the start?
thanks!





This question already has an answer here:




  • Asking the user for input until they give a valid response

    17 answers








python python-3.x






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 14:17









xxMagnumxxMagnum

116




116




marked as duplicate by Thierry Lathuille, Jean-François Fabre python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 14:24


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Thierry Lathuille, Jean-François Fabre python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 22 '18 at 14:24


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2





    Wrap the whole thing in while True:.

    – erip
    Nov 22 '18 at 14:19











  • use elif instead of multiple ifs

    – mad_
    Nov 22 '18 at 14:20











  • Looks like this has been answered before. stackoverflow.com/questions/50498557/…

    – Michael Buchok
    Nov 22 '18 at 14:22














  • 2





    Wrap the whole thing in while True:.

    – erip
    Nov 22 '18 at 14:19











  • use elif instead of multiple ifs

    – mad_
    Nov 22 '18 at 14:20











  • Looks like this has been answered before. stackoverflow.com/questions/50498557/…

    – Michael Buchok
    Nov 22 '18 at 14:22








2




2





Wrap the whole thing in while True:.

– erip
Nov 22 '18 at 14:19





Wrap the whole thing in while True:.

– erip
Nov 22 '18 at 14:19













use elif instead of multiple ifs

– mad_
Nov 22 '18 at 14:20





use elif instead of multiple ifs

– mad_
Nov 22 '18 at 14:20













Looks like this has been answered before. stackoverflow.com/questions/50498557/…

– Michael Buchok
Nov 22 '18 at 14:22





Looks like this has been answered before. stackoverflow.com/questions/50498557/…

– Michael Buchok
Nov 22 '18 at 14:22












1 Answer
1






active

oldest

votes


















1














Uncomment break if you want to end the loop after correct input.



while True:
register = input("have you registered an account?")
if register == "yes":
print("you may proceed to log in")
# break?
elif register == "no":
print("please, create an account")
# break?
else:
print("that is not a valid answer")





share|improve this answer
























  • thank you! it works :)

    – xxMagnum
    Nov 22 '18 at 14:35


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Uncomment break if you want to end the loop after correct input.



while True:
register = input("have you registered an account?")
if register == "yes":
print("you may proceed to log in")
# break?
elif register == "no":
print("please, create an account")
# break?
else:
print("that is not a valid answer")





share|improve this answer
























  • thank you! it works :)

    – xxMagnum
    Nov 22 '18 at 14:35
















1














Uncomment break if you want to end the loop after correct input.



while True:
register = input("have you registered an account?")
if register == "yes":
print("you may proceed to log in")
# break?
elif register == "no":
print("please, create an account")
# break?
else:
print("that is not a valid answer")





share|improve this answer
























  • thank you! it works :)

    – xxMagnum
    Nov 22 '18 at 14:35














1












1








1







Uncomment break if you want to end the loop after correct input.



while True:
register = input("have you registered an account?")
if register == "yes":
print("you may proceed to log in")
# break?
elif register == "no":
print("please, create an account")
# break?
else:
print("that is not a valid answer")





share|improve this answer













Uncomment break if you want to end the loop after correct input.



while True:
register = input("have you registered an account?")
if register == "yes":
print("you may proceed to log in")
# break?
elif register == "no":
print("please, create an account")
# break?
else:
print("that is not a valid answer")






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 14:20









Amadej KastelicAmadej Kastelic

21213




21213













  • thank you! it works :)

    – xxMagnum
    Nov 22 '18 at 14:35



















  • thank you! it works :)

    – xxMagnum
    Nov 22 '18 at 14:35

















thank you! it works :)

– xxMagnum
Nov 22 '18 at 14:35





thank you! it works :)

– xxMagnum
Nov 22 '18 at 14:35



Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python