Q:

How do I match vowels?

I am having trouble with a small component of a bigger program I am in the works on. Basically I need to have a user input a word and I need to print the index of the first vowel.
word= raw_input("Enter word: ")
vowel= "aeiouAEIOU"

for index in word:
    if index == vowel:
        print index

However, this isn't working. What's wrong?

A:

Try:
word = raw_input("Enter word: ")
vowels = "aeiouAEIOU"

for index,c in enumerate(word):
    if c in vowels:
        print index
        break

for .. in will iterate over actual characters in a string, not indexes. enumerate will return indexes as well as characters and make referring to both easier.

A:

Just to be different:
import re

def findVowel(s):
    match = re.match('([^aeiou]*)', s, flags=re.I)
    if match:
        index = len(match.group(1))
        if index < len(s):
            return index
    return -1  # not found

