ezoic

Wednesday, March 15, 2017

Python problem



In English, the present participle is formed by adding the suffix -ing to the infinite form: go -> going. A simple set of heuristic rules can be given as follows:
  1. If the verb ends in e, drop the e and add ing (if not exception: beseefleeknee, etc.)
  2. If the verb ends in ie, change ie to y and add ing
  3. For words consisting of consonant-vowel-consonant, double the final letter before adding ing
  4. By default just add ing
Your task in this exercise is to define a function make_ing_form() which given a verb in infinitive form returns its present participle form. Test your function with words such as lieseemove and hug. However, you must not expect such simple rules to work for all cases.



Partial Solution:


class Solution:
    def make_ing1(self,word1):
        if word1[-1].lower()=='e' and word1[-2].lower()!='i':
            word1=word1[:-1]+"ing"
        elif word1[-1].lower()=="e" and word1[-2].lower()=="i":
            word1=word1[:-2]+"y"+"ing"
        else:
            word1=word1+"ing"
        return(word1)



kk=Solution()
if __name__=="__main__":

    print(kk.make_ing1("like"))


results:








No comments:

Post a Comment

looking for a man

 I am a mid aged woman.  I was born in 1980. I do not have any kid. no complicated  dating before . I am looking for a man here for marriage...