Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # substring_swap.py
- def subswap(t,a,z):
- if '{}' not in t:
- for x in a,z: t = t.replace(x,'{}')
- return t.format(z,a)
- 0
- s = "123 AAA 456 ZZZ 789 (from AAA-to-ZZZ)"
- r = subswap(s,' AAA ',' ZZZ ')
- print r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement