Computer Science Canada

while Loop Help

Author:  mms6 [ Fri Oct 23, 2009 10:30 pm ]
Post subject:  while Loop Help

[copy-pasta of an assignment that's not really relevant]

code:
result = 0

while i <= hi:
        lo += 1
        hi += 1
        result = lo + hi



I get infinite loop

Help anyone?
Thanks

Author:  Tony [ Fri Oct 23, 2009 10:52 pm ]
Post subject:  Re: while Loop Help

mms6 @ Fri Oct 23, 2009 10:30 pm wrote:

code:

while i <= hi:


When is i > hi ?

Author:  andrew. [ Sat Oct 24, 2009 7:28 am ]
Post subject:  RE:while Loop Help

What are the initial values of i and hi? i is probably always less than hi because hi is increasing, and therefore the loop will never end.

Author:  Vish [ Sat Jul 16, 2011 9:14 am ]
Post subject:  Re: while Loop Help

you have not set a variable called i, so therefore, you should get nothing.

the loop doesn't brake until the condition is broken, so, if you want the loop to die, break it.


: