Skip to content

Instantly share code, notes, and snippets.

@t0yohei
Created July 3, 2021 01:20
Show Gist options
  • Save t0yohei/1ca61c4f3f93ec6ccda798524c8e991d to your computer and use it in GitHub Desktop.
Save t0yohei/1ca61c4f3f93ec6ccda798524c8e991d to your computer and use it in GitHub Desktop.
IRREGULAR_HASH = {"stop": "stopped", "go": "gone", "read": "read"}
VOWELS = ["a", "i", "u", "e", "o"]
def verb_past(str):
if IRREGULAR_HASH.get(str):
return IRREGULAR_HASH[str]
elif str[-1] == "y" and not str[-2] in VOWELS:
return str[:-1] + "ied"
elif str[-1] == "c":
return str + "ked"
elif str[-1] == "c":
return str + "ked"
elif str[-1] == "e":
return str + "d"
return str + "ed"
print(verb_past("play"))
print(verb_past("like"))
print(verb_past("try"))
print(verb_past("stop"))
print(verb_past("heat"))
print(verb_past("picnic"))
print(verb_past("go"))
print(verb_past("read"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment