Jun-13-2019, 12:25 AM
(Jun-13-2019, 12:16 AM)Skaperen Wrote: the code i have so far uses a while loop on a list made from a string, that a uses .pop() on it to get items out and [:0] to push an item back in. it works this way but i'd rather have a for loop on a genuine iterator of some kind. making one means a lot of code to add to this project.
cntl = [x for x in cstr] while cntl: ch = cntl.pop(0) if ch == endch: cntl[:0] = [ch] break ... ... while cntl: ch = cntl.pop(0) ...in the above example, the 2nd loop sees the character that ended the first loop as its first character. the real code is much larger than this but this is basically what it does
What are you trying to do?
Are you trying to replace characters in a string?
Are you trying to remove characters in a string?