Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- def past_verb(v):
- vdict = {"be": "been", "go": "gone", "put": "put", "picnic": "picnicked"}
- pp = v +"ed"
- if v in vdict:
- pp = vdict[v]
- else:
- if v[-1] is 'e':
- pp = v + "d"
- elif v[-1] is 'y':
- if len(v) > 2 and v[-2] not in "aeiou":
- pp = v[0:-1] + "ied"
- elif v[-1] not in "aeiou":
- if len(v) > 2 and v[-2] in "aeiou":
- if len(v) > 3 and v[-3] not in "aeiou":
- pp = v + v[-1] + "ed"
- return pp
- print(past_verb("play"))
- print(past_verb("like"))
- print(past_verb("try"))
- print(past_verb("stop"))
- print(past_verb("heat"))
- print(past_verb("picnic"))
- print(past_verb("go"))
- print(past_verb("put"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement