Changing the value of a for loop index on the fly
Gabriel F. Alcober
gfa1977 at yahoo.ca
Wed Mar 23 18:00:23 EST 2005
Uh! I've not even thought in using a while... Thanks!
Lonnie Princehouse wrote:
>i = 0
>while i < len(subject):
> if subject[i] in preps:
> psubject.append(noun_syn_parser(subject[0:i]))
> subject[0:i] = []
> i = 0
> else:
> i += 1
>
>Gabriel F. Alcober wrote:
>
>
>>Hi! There goes a newbie trouble:
>>
>>for i in range(0, len(subject)):
>> if subject[i] in preps:
>> psubject.append(noun_syn_parser(subject[0:i]))
>> subject[0:i] = []
>>
>>Since the last line eliminates some elements of the list, I'm
>>
>>
>wondering
>
>
>>if it's somehow possible to change the value of "i" to 0 in order not
>>
>>
>to
>
>
>>get an index error. Any other ideas?
>>Thanks in advance.
>>
>>
>
>
>
More information about the Python-list
mailing list