Python Forum
How to print only vowels from an input?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to print only vowels from an input?
#7
A combination of "".join() and a generator expression with conditional.
The conditional does containment checking for each char. Before the comparison is made, the char is made lower case.


VOWELS = "aeiou"
text = input("Enter your text: ")

only_vowels = "".join(char for char in text if char.lower() in VOWELS)
no_vowels = "".join(char for char in text if char.lower() not in VOWELS)
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
How to print only vowels from an input? - by PP9044 - Feb-25-2021, 09:54 PM
RE: How to print only vowels from an input? - by DeaD_EyE - Feb-26-2021, 09:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Print user input into triangle djtjhokie 1 2,484 Nov-07-2020, 07:01 PM
Last Post: buran
  Counting Vowels in Python sapphosvoice 1 3,399 May-05-2020, 04:24 AM
Last Post: buran
  How to print the docstring(documentation string) of the input function ? Kishore_Bill 1 3,630 Feb-27-2020, 09:22 AM
Last Post: buran
  Print the longest str from user input edwdas 5 4,292 Nov-04-2019, 02:02 PM
Last Post: perfringo
  Return not vowels list erfanakbari1 2 2,761 Mar-26-2019, 11:37 AM
Last Post: perfringo
  Help with finding vowels nlord7 1 2,325 Feb-27-2019, 04:40 AM
Last Post: ichabod801
  Print The Length Of The Longest Run in a User Input List Ashman111 3 3,274 Oct-26-2018, 06:56 PM
Last Post: gruntfutuk
  Help Formatting Print Statement (input from 3 lists) X 2 Hebruiser 11 6,527 Dec-06-2017, 04:47 PM
Last Post: gruntfutuk
  Functions to remove vowels and extra blanks RiceGum 10 6,013 Nov-17-2017, 05:40 PM
Last Post: heiner55
  How to add user input together then print the result Liwuid_Ocelot 6 5,544 Mar-22-2017, 02:18 AM
Last Post: Liwuid_Ocelot

Forum Jump:

User Panel Messages

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