Skip to content

Instantly share code, notes, and snippets.

@sashiyama
Created July 7, 2018 01:04
Show Gist options
  • Save sashiyama/2f0ccfacb9e9ee95c2288fc93f00d0df to your computer and use it in GitHub Desktop.
Save sashiyama/2f0ccfacb9e9ee95c2288fc93f00d0df to your computer and use it in GitHub Desktop.
verb_post.py
def verb_post(v):
irregular_verb = {"write": "wrote", "go": "went", "read": "read"}
for key, value in irregular_verb.items():
if key == v:
return value
if v[-1] == "c":
return v + "ked"
elif v[-1] == "e":
return v + "d"
elif v[-1] == "y":
if ["a", "i", "u", "e", "o"].count(v[-2]) > 0:
return v + "ed"
else:
return v[:-1] + "ied"
# 実行例
print(verb_post("play"))
print(verb_post("like"))
print(verb_post("try"))
print(verb_post("picnic"))
print(verb_post("write"))
print(verb_post("go"))
print(verb_post("read"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment