ok this is my code;
a = input ("enter first number")
print a
b = input ("entre secound number")
print "addition", a+b
print "multiply", a*b
print ("close?")
text = raw_input ()
if text == "yes":
exit ()
if text == "no":
now at the end i want to loop back to the start if "no" is entered, but i can't seem to get it.
any advise?
many thanks!
Tim
the noob i am!
Started by Timotay, Oct 18 2007 08:59 AM
3 replies to this topic
#1
Posted 18 October 2007 - 08:59 AM
|
|
|
#2
Posted 18 October 2007 - 09:06 AM
This will help you on the way...
choice = ""
while choice != "no":
# This is the start
print "Do you want to try again? Yes/No"
# If the user writes "yes" then it goes back to "This is the start"
# Otherwise, it will quit the loop
# and end here.
print "You decided not to try again, and ended the loop"
#3
Posted 18 October 2007 - 10:08 AM
thanks! i came up with this
choice = ""
while choice!= "no":
a = input ("enter first number")
print a
b = input ("enter secound number")
print b
print "addition", a+b
print "multiply", a*b
print ("retry?")
text = raw_input ()
if text == "yes":
exit ()
very nice! lol, just one question the first line what is the function of the two speach marks?? apart from that i get it!
thanks
Tim
choice = ""
while choice!= "no":
a = input ("enter first number")
print a
b = input ("enter secound number")
print b
print "addition", a+b
print "multiply", a*b
print ("retry?")
text = raw_input ()
if text == "yes":
exit ()
very nice! lol, just one question the first line what is the function of the two speach marks?? apart from that i get it!
thanks
Tim
#4
Posted 19 October 2007 - 12:01 AM
Actually, you can remove that first line, it's not needed. The only thing is does, is to empty the string. I forgot that you don't have to pre-declare Python-variables when I wrote it. So you can simply leave it there or remove it.


Sign In
Create Account

Back to top









