Hi Need a simple Python program to accept a list of 3 items. word_list = ['apple', 'berry', 'melon'] Using a function to convert singular to plural. If item ends with 'y', should replace that with 'ies'. Thanks so much
Need a Python program Singular to Plural
2.2k views Asked by Danny74 At
2
There are 2 answers
1
On
You can use inflect package to produce the plural form.
In [109]: import inflect
In [110]: p = inflect.engine()
In [111]: print([p.plural(word) for word in word_list])
['apples', 'berries', 'melons']
Just make it so that it appends "s" unless the word ends with "y" or some other exception: