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.
-
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
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
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
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
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
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
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
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
> 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
10 matches
Mail list logo