I'm trying to complete this homework problem:
Problem #1: "Write a program that asks the user for a list of nouns (separated by spaces) and approximates the fraction that are plural by counting the fraction that end in "s". Your program should output the total number of words and the fraction that end in "s". You should assume that words are separated by spaces (and ignore the possibility of tabs and punctuation between words).
Problem #2: If we count the number of S's, that'll count all S's in the word, not just the last one. How can I go about figuring out if the last letter in each given word ends with an S. I have this so far:
noun = input("Enter nouns: ")
print("You entered: ", noun)
words = noun.split()
print(words)
amount = len(words)
print(amount)
I don't think I could simply do a words.count('s')
. Any help would be greatly appreciated, thanks.
Following @Billthelizard hint it looks like the easiest solution is this case is:
plurals = noun.count('s ')