In [37]:
def counting():
    print "Please enter the name of the file"
    x=str(raw_input())
    phrase=open(x,"r")
    phrase=(phrase.read())
    count=0
    for i in phrase.split():
        count += 1
    
    print "Found %s words in that file:" %count

In [ ]:


In [38]:
counting()


Please enter the name of the file
countingwords.txt
Found 13 words in that file:

In [ ]: