Counting Words and Characters
Basic length and frequency measurements.
Measuring Text First
Before any fancy analysis, you measure text. Simple counts of characters and words already tell you a lot about a document. 📏
Count Characters With len
The len function returns how many characters a string holds, including spaces and punctuation.
text = "NLP is fun"
print(len(text)) # 10All lessons in this course
- Strings, Characters, and Encodings
- Reading Text Files Into Python
- Counting Words and Characters
- Building Your First Word Frequency Table