Python Forum
Counting vowels in a string (PyBite #106)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Counting vowels in a string (PyBite #106)
#3
(Jul-03-2020, 10:46 AM)buran Wrote: you need to iterate over chars in text and check if char is in vowels

Thank you, my friend!

Here is my script now:

vowels = 'aeiou'
# vowels = ('a', 'e', 'i', 'o', 'u')
result = 0
for char in text:
    if char.lower() in vowels:
        result = result +1
print(result)
The output is exactly: 262. I did it!

I just wish I could have come up with this on my own instead of having to write a long winded, overly analytical question when the solution was so clearly obvious.

Thanks again, @buran. Smile
Reply


Messages In This Thread
RE: Counting vowels in a string (PyBite #106) - by Drone4four - Jul-03-2020, 02:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove vowels in word with conditional ambrozote 12 4,424 May-02-2021, 06:57 PM
Last Post: perfringo
  counting vowels in a string project_science 3 2,689 Dec-30-2020, 06:44 PM
Last Post: buran
  Sorting list of names using a lambda (PyBite #5) Drone4four 2 2,834 Oct-16-2020, 07:30 PM
Last Post: ndc85430
  Uses cases for list comprehension (encountered while doing PyBite #77) Drone4four 3 2,901 Sep-25-2020, 12:14 PM
Last Post: ndc85430
  Using my REPL to bisect numbers and lists with classes (PyBite #181) Drone4four 2 2,149 Sep-24-2020, 01:47 PM
Last Post: Drone4four
  Topic: “Filter numbers with a list comprehension” (PyBite #107) Drone4four 4 2,507 Jun-11-2020, 08:31 PM
Last Post: Drone4four
  Conditionals, while loops, continue, break (PyBite 102) Drone4four 2 3,096 Jun-04-2020, 12:08 PM
Last Post: Drone4four
  Counting the number of letters in a string alphabetically TreasureDragon 2 2,991 Mar-07-2019, 01:03 AM
Last Post: TreasureDragon
  Counting number of characters in a string Drone4four 1 3,528 Aug-16-2018, 02:33 PM
Last Post: ichabod801
  no vowels function alex_bgtv 6 5,198 Jan-01-2018, 08:48 PM
Last Post: alex_bgtv

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020