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 8758343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:31:23+00:00 2026-06-13T14:31:23+00:00

I have a code in Python and want to find vowels in a string.

  • 0

I have a code in Python and want to find vowels in a string.
The code I have written is following….I tried different combinations for using For-Loop, but it throws two different errors;

  1. ‘int’ object is not iterable,
  2. string indices must be integers, not str.

how can I find all vowels in a line?

str1 = 'sator arepo tenet opera rotas'
vow1 = [str1[i] for i in str1 if  str1[i] is 'a' | 'e' | 'o']
  • 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-13T14:31:24+00:00Added an answer on June 13, 2026 at 2:31 pm

    what about:

    vowels = [ c for c in str1 if c in 'aeo' ]
    

    You’re getting errors because when you loop over a string, you loop over the characters in the string (not string indices) and because 'a' | 'e' | 'o' doesn’t make sense for strings — (they don’t support the | operator)

    >>> str1 = 'sator arepo tenet opera rotas'
    >>> vowels = [ c for c in str1 if c in 'aeo' ]
    >>> print vowels
    ['a', 'o', 'a', 'e', 'o', 'e', 'e', 'o', 'e', 'a', 'o', 'a']
    

    One final comment, you shouldn’t use is to test for equality. is tests for identity. A simple test:

    a = 565
    b = 565
    print a == b #True
    print a is b #False (!)
    

    The reason is because a and b reference different objects that have the same value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Want to find piece of the code, written in python, which adds a new
I have a large piece of Python 2 only code. It want to check
I have some python code using shutil.copyfile: import os import shutil src='C:\Documents and Settings\user\Desktop\FilesPy'
I have the following code in python from selenium import webdriver from selenium.webdriver.common.by import
I have some code in a python string that contains extraneous empty lines. I
So I have the following code GAE code in python and it is a
I have a sequence of letters and want to find all combinations of letters
We have an older C++ tool that generates some python code automatically. I tried
So, I have the code, its not done, but all i want it to
I have the following code in Python: def point_to_index(point): if point not in points:

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.