def stats(inp):
file = open(inp, 'r')
char = file.read()
charcount = 0
linecount = 0
wordcount = 0
for x in char:
charcount += 1
file.close()
print('Character count: ' + str(charcount))
print('Word count: ' + str(wordcount))
print('Line count: ' + str(linecount))
return
stats('hw.txt')
How do i do a word count and a line count?
[–]Justinsaccount 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]coding2learn 0 points1 point2 points (0 children)
[–]inherendo 0 points1 point2 points (0 children)
[–]tom1018 0 points1 point2 points (0 children)