Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  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'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement