python - How do I match vowels? -


i having trouble small component of bigger program in works on. need have user input word , need print index of first vowel.

word= raw_input("enter word: ") vowel= "aeiouaeiou"  index in word:     if index == vowel:         print index 

however, isn't working. what's wrong?

try:

word = raw_input("enter word: ") vowels = "aeiouaeiou"  index,c in enumerate(word):     if c in vowels:         print index         break 

for .. in iterate on actual characters in string, not indexes. enumerate return indexes characters , make referring both easier.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -