I'm trying to make a verb conjugator for Spanish. The problem is that I need to get the last two characters in the verb to be able to determine the verb group to which it belongs.
In Spanish, conjugation depends on the verb ending, among other factors. Verbs end in either -ar, -er or -ir. So the program must be able to isolate these two letters and then use conditional structures to determine how to proceed.
But here is the problem:
verb = input("Write the verb here: ") if verb[-2:-1] == 'ar': do this elif verb[-2:-1] == 'er': do this elif verb[-2:-1] == 'ir': do this else: print('you did not provide a verb')
if verb is 'amar', verb [-2:-1] will return 'a', not 'ar'. Can you tell me a way of telling python to isolate from the second to last character up to the VERY last one?
After much thinking I came up with this:
But I don't know if this is the right wayor if this is elegant at all.
Please help me.