Saturday, December 8, 2018

Print Count of vowels using While and For loop in Python

Using while loop:
--------------------

s='Python is a programming language'
count = 0
inc = len(s)
i = 0
while i < inc:
        if s[i] in ('aeiou'):
                count+=1
        else:
                count+=0
        i+=1
print(count)

Using for loop
-----------------

s='Python is a programming language'
count=0
for char in s:
        if char in ('aeiou'):
                count+=1
        else:
                count+=0
print(count)

4 comments:

madhudigitalmarketing said...

Enjoyed reading the article above, really explains everything in detail, the article is very interesting and effective. Thank you and good luck for the upcoming articles Python Programming Training

Ella Smith said...

Great and very accommodating for all the people out there learning the concept of IT and I should also recommend them because it has helped me a lot and I am sure that it will do the same for you! also sharing some information about
https://issuu.com/ccgenerator

Julia Beard said...

you wrote about family . that's a very nice . I am really happy to say it’s an interesting post to read. I learn new information from your article, you are doing a great job. Keep it up and visit my blog online reaction time test.

Julia Beard said...

you wrote about family . that's a very nice . I am really happy to say it’s an interesting post to read. I learn new information from your article, you are doing a great job. Keep it up and visit my blog online reaction time test.