- 3

In the continue statement in while loop...while do they state the number after you have skipped it

While loop

18th Mar 2022, 8:45 AM
Okundaye Jesse Eghosasere
Okundaye Jesse Eghosasere - avatar
18 odpowiedzi
+ 2
Just to be clear. A "continue" statement is just a place holder statement, where the absence of a statement is a syntax error. It doesn't let you skip the loop. If you want to break out of a loop. Then you need to use "break".
18th Mar 2022, 9:20 AM
Mustafa A
Mustafa A - avatar
+ 1
Mustafa A I just tried it again it worked...I copied your code. Thank you very much I appreciate
18th Mar 2022, 2:00 PM
Okundaye Jesse Eghosasere
Okundaye Jesse Eghosasere - avatar
+ 1
Mustafa A I have copied it
18th Mar 2022, 2:00 PM
Okundaye Jesse Eghosasere
Okundaye Jesse Eghosasere - avatar
0
I get you but when I use the continue statement, it still shows the number which I skipped
18th Mar 2022, 12:56 PM
Okundaye Jesse Eghosasere
Okundaye Jesse Eghosasere - avatar
18th Mar 2022, 12:57 PM
Okundaye Jesse Eghosasere
Okundaye Jesse Eghosasere - avatar
0
Okundaye Jesse Eghosasere Share the code. I don't understand what you mean.
18th Mar 2022, 1:00 PM
Mustafa A
Mustafa A - avatar
0
a = 2 while a <= 20: print(a) a = a + 1 if a == 4: print("skipping 4") continue Mustafa A
18th Mar 2022, 1:22 PM
Okundaye Jesse Eghosasere
Okundaye Jesse Eghosasere - avatar
0
Okundaye Jesse Eghosasere Having a continue statement there does nothing at all. If you want to skip 4 then increase "a" again by 1 when "a == 4". Then, the next value will be 5.
18th Mar 2022, 1:26 PM
Mustafa A
Mustafa A - avatar
0
Mustafa A Please I don't get...can you share a code for it...because when I did mine 4 still appeared
18th Mar 2022, 1:30 PM
Okundaye Jesse Eghosasere
Okundaye Jesse Eghosasere - avatar
0
Okundaye Jesse Eghosasere a = 2 while a <= 20: print(a) a += 1 if a == 4: print("skipping 4") a += 1
18th Mar 2022, 1:41 PM
Mustafa A
Mustafa A - avatar
0
Mustafa A I just tried this the output was 1 2 3 "Skipping 4" 4 5 6 7 8 9 10 And ends at 20 Why did 4 still appeared
18th Mar 2022, 1:46 PM
Okundaye Jesse Eghosasere
Okundaye Jesse Eghosasere - avatar
0
Okundaye Jesse Eghosasere Check your indentation. This doesn't make any sense. The print starts at 1 when the lowest "a" gets is 2.
18th Mar 2022, 1:53 PM
Mustafa A
Mustafa A - avatar
18th Mar 2022, 1:55 PM
Mustafa A
Mustafa A - avatar
0
Okundaye Jesse Eghosasere Copy the code and let me know. I am going to delete it afterwards.
18th Mar 2022, 1:58 PM
Mustafa A
Mustafa A - avatar
0
18th Mar 2022, 2:01 PM
Mustafa A
Mustafa A - avatar
0
Mustafa A Why was the a = a + 1 nested within the if clause instead of the while loop
31st Mar 2022, 1:38 PM
Okundaye Jesse Eghosasere
Okundaye Jesse Eghosasere - avatar
0
Okundaye Jesse Eghosasere Because you want to apply the condition to add one more (skip the current a) when a == 4. If it's not inside the if statement, the condition won't apply. A will increase with one more for every a.
31st Mar 2022, 2:15 PM
Mustafa A
Mustafa A - avatar
0
Okay....I understand now Thanks Mustafa A
31st Mar 2022, 2:41 PM
Okundaye Jesse Eghosasere
Okundaye Jesse Eghosasere - avatar