Re: Confused: appending to a list

2006-03-23 Thread DataSmash
Thanks for explaining and all the additional ideas! R.D. -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused: appending to a list

2006-03-23 Thread Fredrik Lundh
"DataSmash" wrote: > I'm confused. Why is it that when I say "while len(list) < 5:", I get > 5 items in my list. > If I say "while len(list) < 6:", I get 6 items in the list and so on. > I would think if I said "less than 5", I would get 4 items. except that you're saying "as long as there are l

Re: Confused: appending to a list

2006-03-23 Thread adam . bachman
You're wanting it to stop when the len(list) == 4, right? The easiest way to change the logic would be to say while len(list) != 4: but that could get you into trouble later on. The problem with the len(list) < 5 expression is that the loop will run "one more time" as long as len(list)

Re: Confused: appending to a list

2006-03-23 Thread skip
R.D.> I'm confused. Why is it that when I say "while len(list) < 5:", I R.D.> get 5 items in my list. If I say "while len(list) < 6:", I get 6 R.D.> items in the list and so on. I would think if I said "less than R.D.> 5", I would get 4 items. Can anyone explain this? Thanks.

Re: Confused: appending to a list

2006-03-23 Thread Rene Pijlman
DataSmash: >I'm confused. Why is it that when I say "while len(list) < 5:", I get >5 items in my list. Because the last time when len(list) was < 5, the block of code following the while executed and did something to the list to give it a length >= 5 (otherwise the block of code would be executed

Re: Confused: appending to a list

2006-03-23 Thread Diez B. Roggisch
DataSmash wrote: > I'm confused. Why is it that when I say "while len(list) < 5:", I get > 5 items in my list. > If I say "while len(list) < 6:", I get 6 items in the list and so on. > I would think if I said "less than 5", I would get 4 items. > Can anyone explain this? Yes - you loop until the

Re: Confused: appending to a list

2006-03-23 Thread Felipe Almeida Lessa
Em Qui, 2006-03-23 às 08:31 -0800, DataSmash escreveu: > I'm confused. Why is it that when I say "while len(list) < 5:", I get > 5 items in my list. "while len(list) < 5:" implies that the loop will stop only when len(list) >= 5. HTH, -- Felipe. -- http://mail.python.org/mailman/listinfo/pyt

Confused: appending to a list

2006-03-23 Thread DataSmash
I'm confused. Why is it that when I say "while len(list) < 5:", I get 5 items in my list. If I say "while len(list) < 6:", I get 6 items in the list and so on. I would think if I said "less than 5", I would get 4 items. Can anyone explain this? Thanks. R.D. # Start an empty list list = [] while