Duplicate strings in a list and add integer suffixes to newly added ones
yield You can use a generator for an elegant solution. At each iteration, yield twice—once with the original element, and once with the element with the added suffix. The generator will need to be exhausted; that can be done by tacking on a list call at the end. def transform(l): for i, x in enumerate(l, … Read more