How to get exact output? : <p>I wrote a program to get words from user and get plural of those words as output. Now I couldn't do following two things</p>

<p>1 - How to restrict only string input i.e if user input integer then program must throw error.</p>

<p>2 - Input - cat mat bat  output-> cats mats bats
    input - cat, mat, bat output -> cat,s mat,s bat,s ( I want to avoid this i.e when user separates the words by comma then i should get bats not bat,s)</p>

<p>please guide me here and please watch out for indentation. </p>

<p>Thank you</p>

<pre><code>`(def plural(user_input):
    # creating list 
    List_of_word_ends = ['o','ch', 's', 'sh', 'x', 'z']
    words = user_input.split()
    ws = "";
    # setting loop to for words
    for word in words:
        if len(word)&gt;0 :
            if word.endswith("y"):
                word = word[:-1]
                word += "ies"
            else:
                isSomeEs = False;
                for suffix in List_of_word_ends:
                    if word.endswith(suffix):
                        word += "es"
                        isSomeEs = True;
                        break
                if not isSomeEs:
                    word += "s"
            ws += word+" "
    print ws
# taking input from user
singular = raw_input("Please enter the words whose plural you want:")
# returns a list of words
x = singular.split(" ")
x = singular.split(",")
#calculate the length of object 
y = len(x)
print "The no. of words you entered is :", y 
#function call
plural(singular))`
</code></pre>
