Christopher Spears wrote: > > if p[start:indexpepper].strip(): > continue > > What is that supposed to accomplish? If the program > can remove whitespace between red and pepper, it's > supposed to move on?
Not quite - p[start:indexpepper] is a string. p[start:indexpepper].strip() is the string with whitespace removed from both ends. The test is true if the string is not empty. So essentially this is testing to see if p[start:indexpepper] contains anything other than whitespace; if so, it the 'continue' is executed which skips the rest of that loop iteration and starts the next. > > p = p[:start] + 'bell' + p[start+lenword:] This builds a new string from pieces of the old one p[:start] - all of p up to but not including the index start p[start+lenword:] - all of p from the index start+lenword to the end > paragraphs[par_no] = p # Change mutable argument! and inserts it into the list of paragraphs (replacing what was there) Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor