how to create a while true loop? [duplicate]
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!
python python-3.x
marked as duplicate by Thierry Lathuille, Jean-François Fabre
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.
add a comment |
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!
python python-3.x
marked as duplicate by Thierry Lathuille, Jean-François Fabre
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 inwhile True:
.
– erip
Nov 22 '18 at 14:19
useelif
instead of multipleif
s
– 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
add a comment |
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!
python python-3.x
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
python python-3.x
asked Nov 22 '18 at 14:17
xxMagnumxxMagnum
116
116
marked as duplicate by Thierry Lathuille, Jean-François Fabre
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
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 inwhile True:
.
– erip
Nov 22 '18 at 14:19
useelif
instead of multipleif
s
– 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
add a comment |
2
Wrap the whole thing inwhile True:
.
– erip
Nov 22 '18 at 14:19
useelif
instead of multipleif
s
– 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 if
s– mad_
Nov 22 '18 at 14:20
use
elif
instead of multiple if
s– 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
add a comment |
1 Answer
1
active
oldest
votes
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")
thank you! it works :)
– xxMagnum
Nov 22 '18 at 14:35
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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")
thank you! it works :)
– xxMagnum
Nov 22 '18 at 14:35
add a comment |
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")
thank you! it works :)
– xxMagnum
Nov 22 '18 at 14:35
add a comment |
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")
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")
answered Nov 22 '18 at 14:20
Amadej KastelicAmadej Kastelic
21213
21213
thank you! it works :)
– xxMagnum
Nov 22 '18 at 14:35
add a comment |
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
add a comment |
2
Wrap the whole thing in
while True:
.– erip
Nov 22 '18 at 14:19
use
elif
instead of multipleif
s– 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