replace_all¶
-
yoda_powers.toolbox.
replace_all
(repls, str)[source]¶ Function that take a dictionnary and text variable and return text variable with replace ‘Key’ from dictionnary with ‘Value’.
- Parameters
repls (dict()) – a python dictionary
str (str()) – a string where remplace some words
- Return type
str()
- Returns
txt with replace ‘Key’ of dictionnary with ‘Value’ in the input txt
Example
>>> text = "i like apples, but pears scare me" >>> print(replace_all({"apple": "pear", "pear": "apple"}, text)) i like pears, but apples scare me