Given a text string, write a Python program to count the number of words in the string.
string = "Python is a powerful programming language"
def count_words(string):
  words = string.split()
  return len(words)

string = "Python is a powerful programming language"
print(count_words(string))