|
||||||
| Python Discussion forum for Python, a high-level language with simple syntax, but yet powerful. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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 |
| Sponsored Links |
|
|
|
|||||
|
This will help you on the way...
Code:
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"
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
|
|||
|
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 |
|
|||||
|
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.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Well, look! A Noob! | maddy1080 | Introductions | 2 | 09-28-2007 07:24 AM |
| Noob Questtion.... | teckmonkey | C and C++ | 2 | 07-27-2007 10:51 PM |
| noob here.. help plz.. | wenwang | General Programming | 2 | 05-15-2007 10:06 AM |
| web dev noob question | jub jub jedi | General Programming | 1 | 03-26-2007 06:41 AM |
| Best Linux for a noob... | PC101 | General Programming | 14 | 09-22-2006 09:21 AM |
| Xav | ........ | 1333.07 |
| MeTh0Dz|Reb0rn | ........ | 1055.7 |
| John | ........ | 881.37 |
| morefood2001 | ........ | 879.43 |
| marwex89 | ........ | 869.98 |
| WingedPanther | ........ | 851.68 |
| Brandon W | ........ | 757.44 |
| chili5 | ........ | 312.39 |
| Steve.L | ........ | 247.05 |
| dcs | ........ | 217.87 |
Goal: 100,000 Posts
Complete: 82%