Selectively replace multiple instances of a character within a string: Difference between revisions
Selectively replace multiple instances of a character within a string (view source)
Revision as of 16:42, 28 July 2022
, 1 year ago→Python
m (→Python) |
m (→Python) |
||
Line 530:
deltas = ruleMap.get(c, [])
return (
dict(a, **{c: 1 + i}) if c in ruleMap else a,
deltas[i] or c if i < len(deltas) else c
)
|