daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. changeWords(“I can't eat") -> “I can not eat"
  2. changeWords(“I don't like swimming.”) -> “I do not like swimming.”
  3. changeWords(“I shouldn't do that.”) -> “I should not do that.”
  4.    
  5. def stringChange(a):
  6. a = ""
  7. for line in stringChange("a"):
  8.     line = text.replace("a","can't","can not")
  9.     if not line: break
  10.     return line
  11.    
  12. >>> def changeWords(s):
  13.         for old, new in (
  14.                 ("can't", "can not"),
  15.                 ("shouldn't", "should not"),
  16.                 ("don't", "do not"),
  17.             ):    
  18.             s = s.replace(old, new)
  19.         return s
  20.  
  21. >>> changeWords("I don't know how to do this")
  22. 'I do not know how to do this'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top