Hello, i'm new to this forum and to Python and i want to creat a function that counts the number of words on .txt file, but also that creats a dictionary with it, with the words has a key and the number of referencies to it has a value.
Thanks and best regards,
Luis Ventura
Luis Ventura
0
Newbie Poster
Recommended Answers
Jump to PostSounds like an application for collections.Counter.
First do the Python tutorial to learn the Python language.
http://docs.python.org/py3k/tutorial/index.html
Then review the library reference to get an overview of Python's built in …
Jump to PostYou should remove while and readline, For should be after opening the file, after current line 6. ..
Jump to Postchange line 6 condition.
Jump to PostNo it is not: you should be able to call the function like
print(words('texto.txt'))
(and you left in the old condition which was less strict)
Jump to PostBy fixing the parameter to be filename like specified.
All 37 Replies
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
TrustyTony
888
pyMod
Team Colleague
Featured Poster
lrh9
95
Posting Whiz in Training
vegaseat
commented:
very nicely said
+15
Luis Ventura
0
Newbie Poster
lrh9
95
Posting Whiz in Training
Luis Ventura
0
Newbie Poster
lrh9
95
Posting Whiz in Training
Luis Ventura
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
Luis Ventura
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
Luis Ventura
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
Luis Ventura
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
Luis Ventura
0
Newbie Poster
lrh9
95
Posting Whiz in Training
Luis Ventura
0
Newbie Poster
lrh9
95
Posting Whiz in Training
Luis Ventura
0
Newbie Poster
Luis Ventura
0
Newbie Poster
snippsat
661
Master Poster
Luis Ventura
0
Newbie Poster
snippsat
661
Master Poster
Luis Ventura
0
Newbie Poster
Luis Ventura
0
Newbie Poster
snippsat
661
Master Poster
Luis Ventura
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.