Write a function in Python that counts the number of words in the given string.
Example String:
"This is a sample string with some words"
def word_count(str):
 words = str.split()
 return len(words)

print(word_count("This is a sample string with some words"))