-1

I need to to define a function make_3rd_form() which given a verb in infinitive form returns its third person singular form.

The third person singular verb form in English is distinguished by the suffix-s, which is added to the stem of the infinitive form: run-> runs.

these are the rules: If the verb ends in y, remove it and add ies

If the verb ends in o, ch, s, sh, x or z, add es

By default just add s.

I think that string method ends with() is the way.

I am new to python so any type of idea would be helpful.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • 2
    Is this homework? What have you tried so far? – Mike Dinescu Jan 10 '14 at 02:51
  • Try posting some code first, so we can see what direction you're going – SobiborTreblinka Jan 10 '14 at 02:53
  • What you are asking is an algorithm. This is not the place for this kind of question. – Victor Schröder Jan 10 '14 at 02:54
  • This is a programming question @VictorSchröder . I will post what I got as soon as I got something to post. I am still trying to figure out ways to do it. – user3179932 Jan 10 '14 at 03:27
  • @user3179932, no, it is not. This is a request for people write the programm for you, what is definitly not the subject of this community. If you'd written a piece of code and some function didn't worked, it's ok to ask. But request people to do the whole thing? Nop. This is against even to your own learning. – Victor Schröder Jan 10 '14 at 09:50

2 Answers2

0
def make_3rd_form():
    word = raw_input('Please enter a word: ')
    if word[len(word)-1] == 'o' or word[len(word)-1] == 's' or word[len(word)-1] == 'x' or word[len(word)-1] == 'z':
        word = word + 'es'
        print word
    elif word[len(word)-2] == 'c' and word[len(word)-1] == 'h':
        word = word + 'es'
        print word
    elif word[len(word)-2] == 's' and word[len(word)-1] == 'h':
        word = word + 'es'
        print word
    elif word[len(word)-1] == 'y':
        word = word[:-1]
        word = word + 'ies'
        print word
    else:
        word = word + 's'
        print word

make_3rd_form()

Is this what you were thinking of? I hope so! However, if one of the requirements was to use with(), sorry, because clearly I didn't.

A.J. Uppal
  • 19,117
  • 6
  • 45
  • 76
0
def make_3rd_form(verb):
    es = ('o', 'ch', 's', 'sh', 'x', 'z')
    if verb.endswith('y'):
        return re.sub('y$', 'ies', verb)
    elif verb.endswith(es):
        return verb + 'es'
    else:
        return verb + 's'
garg10may
  • 5,794
  • 11
  • 50
  • 91