Generate a function in Python that takes a string and counts the number of capitalized letters.
"ViVaViVaViVa"
def countCapitalized(str): 
    count = 0
    for i in range(len(str)): 
        if str[i].isupper():
            count += 1
    return count

print(countCapitalized("ViVaViVaViVa"))