After a long break I'm having another foray into the world of programming in Python, and I'm really stuck with something. Loops. I think.
I think I need to use a loop for the desired effect, but I'm not sure. Basically what I want to do is this:
- Ask the user a question, expecting a yes or no input
- If they say yes, do one thing
- If they say no, do another thing
- If they input anything other than yes or no, repeat the question.
I want to loop in the sense that I want it to keep repeating the question until a sufficient answer is given. But having looked at several tutorials and online sources, I can't get my head around how to use a loop for anything more than a very basic "keep doing x until y is z", typically like this:
- Code: Select all
x = 1
while x < 10:
x = x + 1
The problem is I don't want it to just keep doing something, I want it to actually return to an earlier point in the code, and continue from there, not do the same thing over and over. Or am I looking at this the wrong way?
Someone please enlighten me!