Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
wordcount.py
SUBMITTED BY:
Guest
DATE:
Sept. 13, 2014, 3:56 a.m.
FORMAT:
Python
SIZE:
515 Bytes
Raw
Download
Tweet
HITS:
801
Go to comments
Report
import
string
# If you don't then write down the whole list of strings a-zA-Z
count
=
0
try
:
# Counting user input is too much easy
fname
=
open
(
raw_input
(
"Enter File name : "
))
.
read
()
# Warning, len(fname) cannot be used.
# Because it also counts all those spaces.
except
IOError
:
print
"File not found!"
else
:
for
i
in
fname
:
if
i
in
string
.
ascii_letters
:
# if i in a-zA-Z
count
+=
1
print
"Word Count is :
%s
"
%
count
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus