How can I best find out how many times a word appears in a text?

you should read the docs more. also googling with "Python word count" will show you some links to what you are looking for.

Searching our own Python snippet section there are several hits under 'wordcount' and word frequency. These snippets are probably more complex than what you need, so here is a very simple way to do it ...

# Chinese wisdom ...
str1 = """Man who run in front of car, get tired.
Man who run behind car, get exhausted."""
print str1.count('Man')  # 2

BTW, Google result --> about 1,110,000 for python word count . That should keep you busy for the next ten years.

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.