i found this code here and i tested the code and it isn't working for me
this is what my code looks like:
# PURPOSE: to count the number of words, lines, and characters in a file
#
# INPUT(S): a file name to be used
#
# OUTPUT(S): count for number of lines, words, and characters in the file
#
# EXAMPLES: input: ; output:
# input: ; output:
#
################################################################################
import string
def fileCount():
lineCount = 0
wordCount = 0
charCount = 0
list = []
fname = raw_input('Enter the name of the file to be used: ')
infile = open(fname, 'r')
for range in infile:
lineCount = lineCount + 1
list = string.split(readline, '')
wordCount = wordCount + len(list)
for ch in file:
charCount = charCount + 1
print "There are", lineCount, "lines in the file."
print "There are", charCount, "characters in the file."
print "There are", wordCount, "words in the file."
infile.close()
fileCount()
im getting an error in the python shell and it is below.
list = string.split(line, '')
NameError: global name 'line' is not defined
since i found this code somewhere else and the thread is posted as solved im guessing that i did something wrong when i re-wrote it to test. any help is appreciated, thank you!