Create a string function in Python to convert all words in a string to uppercase.
string = "this is a sample string"
def to_upper(string):
 return string.upper()
 
print(to_upper(string))  # THIS IS A SAMPLE STRING