Re: while Loops

2016-06-22 Thread John Gordon
In <[email protected]> Elizabeth Weiss writes: > Why is one of the results 5 since i=i+1? Should the maximum result > be 4 since 4 +1=5? "while i<=5" means "while i is less than or equal to 5". So the loop will keep going at 5, and only stop when i is 6. -

Re: while Loops

2016-06-22 Thread alister
On Tue, 21 Jun 2016 20:50:24 -0700, Elizabeth Weiss wrote: > i=1 while i<=5: >print(i) >i=i+1 > > The result is: > 1 > 2 > 3 > 4 > 5 > > Why is one of the results 5 since i=i+1? Should the maximum result be 4 > since 4 +1=5? > > Thanks for your help! check you loop condition while i le

Re: while Loops

2016-06-21 Thread Michael Torrie
On 06/21/2016 09:50 PM, Elizabeth Weiss wrote: > i=1 > while i<=5: >print(i) >i=i+1 > > The result is: > 1 > 2 > 3 > 4 > 5 > > Why is one of the results 5 since i=i+1? Should the maximum result be 4 since > 4 +1=5? > > Thanks for your help! If you trace the execution through in your m

Re: while Loops

2016-06-21 Thread Ben Finney
Elizabeth Weiss writes: > Why is one of the results 5 since i=i+1? What do you think ‘i = i + 1’ means? (Asking because your idea of what that means may be affecting how you expect the loop to behave.) > Should the maximum result be 4 since 4 +1=5? Try “thinking like the computer”: perform the

Re: while Loops

2016-06-21 Thread Rustom Mody
On Wednesday, June 22, 2016 at 9:20:35 AM UTC+5:30, Elizabeth Weiss wrote: > i=1 > while i<=5: >print(i) >i=i+1 > > The result is: > 1 > 2 > 3 > 4 > 5 > > Why is one of the results 5 since i=i+1? Should the maximum result be 4 since > 4 +1=5? > Not sure what your question is But I gue

Re: while Loops

2016-06-21 Thread Wildman via Python-list
On Tue, 21 Jun 2016 20:50:24 -0700, Elizabeth Weiss wrote: > i=1 > while i<=5: >print(i) >i=i+1 > > The result is: > 1 > 2 > 3 > 4 > 5 > > Why is one of the results 5 since i=i+1? Should the maximum result be 4 since > 4 +1=5? > > Thanks for your help! The operator '<=' means less th

Re: while-loops enter the last time after condition is filled?

2008-04-07 Thread [EMAIL PROTECTED]
On 6 avr, 01:53, [EMAIL PROTECTED] wrote: > it seems to me from my results that when i use a while-loop it will > execute once after the condition is met. > > ie the conditions is met the code executes one time more and then > quits. The problem is obviously in your code, but since you failed to p

Re: while-loops enter the last time after condition is filled?

2008-04-06 Thread Sumit
On Apr 6, 4:53 am, [EMAIL PROTECTED] wrote: > it seems to me from my results that when i use a while-loop it will > execute once after the condition is met. Perhaps your condition is wrong. Please provide the code where this occured. -- http://mail.python.org/mailman/listinfo/python-list

Re: while-loops enter the last time after condition is filled?

2008-04-05 Thread John Machin
On Apr 6, 9:53 am, [EMAIL PROTECTED] wrote: > it seems to me from my results that when i use a while-loop it will > execute once after the condition is met. > > ie the conditions is met the code executes one time more and then > quits. The syntax is this: while condition: do_something

Re: while-loops enter the last time after condition is filled?

2008-04-05 Thread Tim Chase
> it seems to me from my results that when i use a while-loop it > will execute once after the condition is met. Nope. > ie the conditions is met the code executes one time more and > then quits. Must be that your conditional is wrong, or your conditions are not updated the way you think they a