QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Count Words

Counts the number of words in a string

  • string
  • word
  • count
  • word-count

Code

def count_words(s):
    return len(s.split())

Usage

System.out.println(countWords("hello world")); // 2