Construct a function in Python which takes in a string and returns the number of vowels it has.
string="hello world"
def countVowels(string):
    
    vowels = 'aeiouAEIOU'
    count = 0

    for char in string:
        if char in vowels:
            count += 1
    
    return count