Advertisement
DeaD_EyE

multi replacements

Jan 1st, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. def replace_text(text, replacements):
  2.     for old, new in replacements:
  3.         text = text.replace(old, new)
  4.         # text will be reassigned inside the function
  5.         # the text outside is not modified (call by reference)
  6.     # after all replacements, the changed text is returned by this function
  7.     return text
  8.  
  9. replacements = [
  10.     ("Зсбн","3 fM"), ("2сбн", "2 fM"),
  11.     ("3сбн", "3 fM"), ("4сбн", "4 fM"),
  12.     ("6сбн", "6 fM"), ("круг", "Runde"),
  13.     ("ряда", "mal"),
  14.     ]
  15.  
  16. text = "Зсбн‚ прибавка, 3сбн‚ (3с6н‚ прибавка)-3раза‚ 3сбн,Зсбн, прибавка-2раза=36сбн"
  17. print(text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement