Movatterモバイル変換


[0]ホーム

URL:


for loop troubles

Alex Martellialeaxit at yahoo.com
Fri Apr 27 04:06:57 EDT 2001


"Jeff Shipman" <shippy at nmt.edu> wrote in messagenews:3AE8EFCC.CEFCF61F at nmt.edu...> I've used this method before to do funky for loop> stuff, but for some reason, I'm getting a line skipped> this time.    ...>       for line in linelist:    ...>                linelist.pop(j)    ...> doesn't. I'm assuming it must have something to> do with my linelist.pop(j), but I do something similar> to this in several other locations in the program> and I've done it in other programs with no odd> problems. Basically, I'm doing that to get rid of> all the lines I'm passing to the recursive call.Modifying the sequence that you're looping on whileyou're looping on it will often give surprisingresults.  If you do it in several other locationsand it hasn't been biting you, you may have beenlucky (or unlucky, depending on one's viewpoint:-).I would suggest a different approach -- do a simpleloop without deletion nor recursion, just keepingtrack of 'state' ("how deeply nested am I") soyou can decorate the output with the appropriate<UL>, </UL> and <LI> tags as depth increases/decreases/stays above 0.Alex


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp