0
what 1==1 means in while loop?
5 odpowiedzi
0
i need to know the logic... like what does it represents; when we are initiating a variable let suppose
i=0
while 1==1:
i=i+1
print i
0
while 1==1 will become an infinite loop, as 1 is always 1. That will never change.
0
If we do:
i=0
while 1==1:
# This will become an infinite loop, as one will always equal one
# Do not have loops like this without a break statement, which can be used to exit loops
i=i+1
if i == 50:
# Once i is 50 let's exit the loop
break
print i
# Output: 50
0
If you declare 1==1 than while loops run infinitly becz 1==1 is always true
0
In 1 == 1, an equality operator is performed, and a boolean is returned.
1 == 1 -> True
while will run it's code, and will return back to test the "1 == 1" condition again and repeat this, until the condition is False, a break statement is found, or the whole program is aborted.