Python Forum

Full Version: Function producing no result
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
def Tester():
	condition = 10
	while condition !=0:
		continue
	condition = condition -1
	if condition == 0:
		print ("You got it right")
	else: 
		print("you got it wrong")

Tester()
When i execute this, why does the result come blank?
You put continue, which is not needed at all. Not to mention that the code you want to loop is not even in the loop. Get rid of the continue statement and indent the code you want under the while loop.
Your code won't work because of the "continue". Continue is not needed for a while loop unless you want to skip parts of the while loop when a condition within the loop itself is met.

What you must do: Remove continue, and add an indent to all those statements within the while loop (i.e everything below while loop).

What is actually happening: The 'to be looped' is not even being considered within the loop. And even if it were, continue would make it so that they were never executed.

Continue makes it so that the other parts of the loop iteration are not executed.