Created
July 3, 2021 01:20
-
-
Save t0yohei/1ca61c4f3f93ec6ccda798524c8e991d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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