GazEcc GazEcc - 6 months ago 23
Python Question

Calling formatting in python to conjugate verbs

I'm trying to get a print of the verb to be in English conjugated by python

My code is:

verbFormat = ["I","you","he","she","we","they","yee",]
verbConjBePresent = [{0} + "am", {1} "are", {2} "is", {3} "is", {4} "are", {5} "are", {6} "are",]
print(verbConjBePresent.format(verbFormat))


I have tried adding {x} + "str" in the vCBP and tried without.

I have tried using tuples instead of lists

EDIT: The Reason I want to use the list "verbFormat" is so I don't need to re-itterate those words every time I change verb (and it should cover most tenses for most verbs)

Answer

Your string formatting is wrong. You're trying to format a list.

verbFormat = ["I","you","he","she","we","they","yee"]
verbConjBePresent = "{0} am;{1} are;{2} is;{3} is;{4} are;{5} are;{6} are"
print(verbConjBePresent.format(verbFormat).split(';'))

With the split(';') you will print a list with conjugations. If you want all together in a string, just remove split.

Comments