"continue" applies to loops.
It will simply stop the current iteration and jump into the next. So basically keep typing what you are typing until you type what the program expects of you.
Answer from Andrei Dragotoniu on Stack Overflow"continue" applies to loops.
It will simply stop the current iteration and jump into the next. So basically keep typing what you are typing until you type what the program expects of you.
Understand that continue does not break out of if and elif statements. Continue only breaks out of looping statements.
If continue is used within an if block which is present inside a loop, it skips the current iteration of the loop. So when continue is encountered, control moves to the beginning of the loop skipping any statements after continue. In this program, if user enters 'multiple letters', an 'already guessed letter' or a 'non-alphabet', continue comes into play and the program just skips that iteration and goes on to accept another letter.
while cond1:
if cond2:
continue
#code
So here, if cond2 is satisfied, continue is encountered and #code is not executed. It just goes to the while cond1: again and continues the loop
if and continue vs elif
Struggling with combining while loop, if statement and try block
How continue works in while loop
Can't understand "Continue" function in Python statement(for loop, while loop) !!
Videos
I am new to learning Python or rather I say new to programming. So, anyway
Can anyone help me understanding the "continue" function in Python statement(for loop while loop etc) or help me with a link with broad explanation?
I get "break" , "pass" but can't quite understand the use of "continue".
I'm very early on in learning python, and have been going along with Jose Portilla's complete python bootcamp at Udemy.
I recently completed the statements assessment. One of the questions was to write a program that prints the integers from 1 to 100. But for multiples of three print "Fizz" instead of the number, and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
For some reason, I completely forgot about elif, and instead completed the task with three if statements, placing a continue after each.
Can anyone help me to understand the reason as to why this method gives the same result as an if statement and two elifs?
EDIT: also, before using continue, the output would show “Fizz” for 3, then show 3 separately below, but only show “Buzz” for 5. I still don’t really understand that either.