Quantcast
Channel: Python Archives - Tutorials Made
Viewing all articles
Browse latest Browse all 24

Python program to Strip Vowels from a String!

$
0
0

In this post, we are going to see how to write a PHP script to strip vowels from strings. This post could be useful for school/college students or beginner Python learners. I will use “array” and “for loop” to strip the vowels.

#Python script to strip vowels from a string
print ("Enter a string:")

#get the input string
inpstr = input()

#define a string
output = ""

#convert string to lower case
inplower = inpstr.lower()

#set the vowels in an array
vowels = ['a','e','i','o','u']

#loop through each character 
for c in inplower:
    #if vowel found then concate
    if c in vowels:
        output = output + c

#print output
print ("Vowels are: "+ output)

Just read the in-line comments to understand the script.

Example output of the above script:

Enter a string:
agurchand
Vowels are: aua

Thanks for reading. Enjoy programming!

The post Python program to Strip Vowels from a String! appeared first on Tutorials Made.


Viewing all articles
Browse latest Browse all 24

Latest Images

Trending Articles



Latest Images