Re: [Tutor] In-place changes on loops

2005-02-03 Thread Danny Yoo
> But let's change it to what I think you were thinking of: > > ### > def lstrip(string, chars): > scratchspace = list(string) ## get a mutable list of characters > for x in scratchspace: > if x in chars: > scratchspace[i] = '' > return ''.join(scratchspace)

[Tutor] In-place changes on loops

2005-02-03 Thread Danny Yoo
On Thu, 3 Feb 2005, Sandip Bhattacharya wrote: > >for x in string: > >if x in chars: > >string[i] = '' > > I just have a hangover from other languages, but I really wanted to know > how Python handles iteration over a variable which is being changed > within the loop itse