My Question:
I have this exercise ;
If the verb ends in e, drop the e and add ing (if not exception: be, see, flee, knee, etc.)
If the verb ends in ie, change ie to y and add ing
For words consisting of consonant-vowel-consonant, double the final letter before adding ing
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 lie, see, move and hug. However, you must not expect such simple rules to work for all cases.
My code:
def make_ing_form():
a = raw_input("Please give a Verb: ")
if a.endswith("ie"):
newverb = a[:-2] + "y" + "ing"
elif a.endswith("e"):
newverb = a[:3] + "ing"
elif a[1] in "aeiou":
newverb = a + a[-1] + "ing"
else:
newverb = a + "ing"
print newverb
make_ing_form()
With this code all is gut , but when i change the placement ;
def make_ing_form():
a = raw_input("Please give a verb: ")
if a.endswith("e"):
newverb = a[:3] + "ing"
elif a.endswith("ie"):
newverb = a[:-2] + "y" + "ing"
elif a[1] in "aeiou":
newverb = a + a[-1] + "ing"
else:
newverb = a + "ing"
print newverb
make_ing_form()
the answer who i come are not on present participle , how i Understand here http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#python-has-names , when the identifier change to another statement ( from If to Elif), it "forget" the if statement .If that's the case , why i to receive this result ?
sorry about my English ....
In the second code it will never enter the first elif ( elif a.endswith("ie"): ) because if a verb ends in ie (ex. lie) it would enter the if, as lie ends in e. You should have the condition as in the first code. If you have more problems with your first code let me know.