Hi
Ive got this word count script when i check it there is no probs but when i run it it says
Traceback (most recent call last):
File "H:\Scripts\count.py", line 9, in <module>
infile = file(data, 'r')
NameError: name 'data' is not defined
This is my script
#The number of lines, and the number of words.
import string
def main():
data = raw_input("H:\harry.txt")
infile = file(data, 'r')
data_file = infile.read()
number_of_characters = len(data_file)
print "The number of characters in your text is", number_of_characters
list_of_words = string.split(data_file)
number_of_words = len(list_of_words)
print "The number of words in your text is", number_of_words
infile.close()
secondfile = file(data, 'r')
line_of_text = secondfile.readlines()
print line_of_text
number_of_lines = len(lines_of_text)
print "The number of lines in your text is" , number_of_lines
infile.close()
main()
can anybody tell me what is wrong with line 9
Thanks
HLA91
STAY COOL AND DONT GET STRESSED!:cool: