SHARE
TWEET

Untitled

a guest Jul 17th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def past_verb(s_verb):
  2.     d = {'play': 'played',
  3.          'stop': 'stopped',
  4.          'go': 'gone',
  5.          'put': 'put'}
  6.  
  7.     str = d.get(s_verb)
  8.  
  9.     if str is None:
  10.         # y -> ied
  11.         if s_verb[-1:] == 'y':
  12.             str = s_verb[:-1] + 'ied'
  13.         # e -> ed
  14.         elif s_verb[-1:] == 'e':
  15.             str = s_verb[:-1] + 'ed'
  16.         # c -> ked
  17.         elif s_verb[-1:] == 'c':
  18.             str = s_verb + 'ked'
  19.         else :
  20.             str = s_verb + 'ed'
  21.  
  22.     return str
  23.  
  24.  
  25. print(past_verb("play"))
  26. print(past_verb("like"))
  27. print(past_verb("try"))
  28. print(past_verb("stop"))
  29. print(past_verb("heat"))
  30. print(past_verb("picnic"))
  31. print(past_verb("go"))
  32. print(past_verb("put"))
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top