Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

Ending a loop

 
Joey McGee
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Report post to moderator
Below is the code where I've created a loop and am trying to code it to end if the user types in no... If anyone could help me with this it would be greatly appreciated.
 
Emanuel Kadziela
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Report post to moderator
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Report post to moderator
break statement would do the job, of course in your case combined with proper check for user input.
 
Campbell Ritchie
Sheriff
Posts: 48445
56
  • Mark post as helpful
  • send pies
  • Report post to moderator
If you are going to have that do‑while loop, you are far better writing it like thisYou will have to check whether answer is still in scope if it is declared inside the loop.
 
    Bookmark Topic Watch Topic
  • New Topic