Counting total number of consonants in a string in iterative way using Python (Google Interview Question)

string = 'Sayan'
viowels = 'aeiou'
count=0
for items in range(len(string)):
    if string[items].lower() not in viowels and string[items].isalpha:
        count+=1
print(count)

Leave a comment