Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9227661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:08:04+00:00 2026-06-18T05:08:04+00:00

For this code I pretty much have it so that it will return certain

  • 0

For this code I pretty much have it so that it will return certain indices, but it counts multiple vowels in the same index. I just realized that index() only returns the first occurrence of the item, but now I’ve pretty much exhausted other possibilities.

def vowel_indices(s):
'string ==> list(int), return the list of indices of the vowels in s'
res = []
for vowel in s:
    if vowel in 'aeiouAEIOU':
        res = res + [s.index(vowel)]
return res

An example of this working is:

vowel_indices(‘hello world’)

[1, 4, 7]

Instead I end up getting [1,4,4] as the return.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:08:06+00:00Added an answer on June 18, 2026 at 5:08 am

    Use a list comp with enumerate:

    vowel_indices = [idx for idx, ch in enumerate(your_string) if ch.lower() in 'aeiou']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is pretty much the same problem i have, except with very different code:
Valgrind is complaining about some of my code, but this code is pretty much
Pretty much what the title says really. We have some code that is .NET
This code is not pretty, but I want to print out the last generated
I'm pretty sure there's some quick and easy error in this code but somehow
I have this code: $coder = JSON::XS->new->utf8->pretty->allow_nonref; %perl = $coder->decode ($json); When I write
I am pretty new at C# and .NET, but I've made this code to
this is just some pretty standard code I have tried. What I am trying
Ok I will try to explain this as much as possible. I have a
I'm pretty much just looking for the code they used that is very similar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.