Friday, August 27, 2021

Remove Vowels and Consonants in Python

 Write a Python program that will ask the user to give any string and then the program will remove and display the vowels and consonants in the given string by the user.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.


My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.






Program Listing

# vowels_Consonants.py
# Author : Jake Rodriguez Pomperada, MAED-IT, MIT
# www.jakerpomperada.blogspot.com and www.jakerpomperada.com
# jakerpomperada@gmail.com
# Bacolod City, Negros Occidental Philippines

# Remove all consonents and vowels from string
# Using list comprehension
print()
print("\tRemove Vowels and Consonants in Python")
print()
string = input('Enter any string: ')

print()

remove_vowels = "".join([chr for chr in string.lower() if chr in "aeiou"])
print("String Without Consonants : " + str(remove_vowels.upper()))
remove_consonants = "".join([chr for chr in string.lower() if chr
in "bcdfghjklmnpqrstvwxyz"])
print("String Without Vowels : " + str(remove_consonants.upper()))
print()
print("\tEnd of Program")
print()


No comments:

Post a Comment