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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#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:
1 2 3 |
Enter a string: agurchand Vowels are: aua |
Thanks for reading. Enjoy programming!