Hello, I am doing some beginner exercises and have been looking around for the internet for an answer to this question, but haven't found one that's entirely applicable.
What I'm looking for the program to do is return to the initial question if the user types in a variable less than 1 or greater than 5.
Sorry, I realize this may be a very n00b question, but I assure you I have looked around for an answer.
If you're still struggling with using while loops. Basically it's just a condition that allows a section of your code to repeat until that condition changes in some way.
The while loop above will ONLY loop that statement whilst "quit" is false. The loop will end once "quit" becomes true. The above code is actually an infinite loop because "quit" never becomes true as you can see.
The code below however, you can clearly see that I change the boolean variable to true after "bob" has been printed to the console. That while loop would only execute once.
Sorry, I'm a super noob :) there is an cleaner way to do it but I thought that his program was just for fun and it wouldn't really matter. My way is just a simple fix for what you are trying to do. If your program needs to look nice or is an assignment, then sausage's way is what you are looking for. Sausage's method will develop better coding habits too and is overall a better method.
Thanks for the catch! Can't believe I didn't realize that XD It's nice to see a friendly community of programmers of all skill levels helping each other out.