Break and Continue: While Loops
rustompmody at gmail.com
Thu Jun 23 01:05:56 EDT 2016
On Thursday, June 23, 2016 at 9:47:23 AM UTC+5:30, Elizabeth Weiss wrote:
> CODE #1:
> while 1==1:
> if i>=5:
> I understand that i=0 and i will only be printed if 1=1
> The results of this is
> Why is Breaking going to be printed if i only goes up to 4? It does say if i>=5? Shouldn't this mean that the results should be:
> CODE #2:
> while True:
> if i==2:
> print("Skipping 2")
> if i==5:
> 1. what does the word True have to do with anything here?
> 2. i=i+1- I never understand this. Why isn't it i=i+2?
> 3. Do the results not include 2 of 5 because we wrote if i==2 and if i==5?
> 4. How is i equal to 2 or 5 if i=0?
> Thanks for all of your help!
I suggested in your other post (Subject While Loops)
that the predecessor of python ABC's syntax for assignment would help unconfuse you
ie the ASSIGNMENT x=y we write as PUT y IN x
Using that rewrite your CODE 1 as
PUT 0 in i
PUT i+1 IN i
Now try and rethink what that does
Then repeat for your other examples that confuse
More information about the Python-list