I understand that the following is an infinite loop (until you break out of it):
while True:
So then, what would be the need to ever use the following:
while False:
Or:
while not True:
Since the while loop only executes the code below if the while (condition): evaluates to the boolean True, is it correct to assume that the "code" show below would never execute?:
while False:
code
while only executes the loop body if the expression evaluates to a true value.
As such, hardcoding the expression to False (or anything that always produces False or other false value), has no use other than to ensure the loop block is not executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With