Skip to content
Related Articles

Related Articles

Python | TextBlob.word_counts() method
  • Last Updated : 09 Sep, 2019

With the help of TextBlob.word_counts() method, we can get the word count of a particular word in the sentence by using TextBlob.word_counts() method.

Syntax : TextBlob.word_counts()
Return : Return the count of word in a sentence.

Example #1 :
In this example we can say that by using TextBlob.word_counts() method, we are able to get the count of word in a sentence.

filter_none

edit
close

play_arrow

link
brightness_4
code

# import TextBlob
from textblob import TextBlob
  
gfg = TextBlob("I am confused sometime, sometime I messed up things.")
  
# using TextBlob.word_counts() method
gfg = gfg.word_counts['sometime']
  
print(gfg)

chevron_right


Output :

2



Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# import TextBlob
from textblob import TextBlob
  
gfg = TextBlob("My name is Khan khan KhaN.")
  
# using TextBlob.word_counts() method
gfg = gfg.word_counts['khan']
  
print(gfg)

chevron_right


Output :

3

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :