i trying figure out why getting empty list when code ran. goal take string, find index of vowels , append index list. index starting @ 1 instead of zero. tips error might occurring great! if there general oversight notice please let me know. relatively new python.
def vowel_indices(word): vowels = ["a", "e", "i", "o", "u"] vowel_idx = [] word.lower() idx, letter in enumerate(word, start = 1): if letter == vowels: vowel_idx.append(idx) return vowel_idx
if letter == vowels:
should if letter in vowels:
vowels list , string can never equal list , should move return out of loop stop function in it's track first time loops through
Comments
Post a Comment