Does while loop can use as if else statement? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Does while loop can use as if else statement?

when i use while loop i have found that it is like the if statement

15th Sep 2019, 5:09 PM
Sabyasachi Pramanik
Sabyasachi Pramanik - avatar
2 Answers
+ 2
It may be possible in some cases, but the meaning of while is different: if/else tells a piece of code to run *once* (if condition true). while tells code to run *multiple times* (as long as condition true).
15th Sep 2019, 5:17 PM
HonFu
HonFu - avatar
+ 1
Yes, you can use it like an if statement, but not an else statement, also it's unnecessary.
15th Sep 2019, 5:14 PM
Airree
Airree - avatar