[Tutor] (no subject)

Lucas Prado Melo lukepadawan at gmail.com
Tue Sep 8 16:25:48 CEST 2009


On Tue, Sep 8, 2009 at 10:48 AM, shellcom3 at juno.com <shellcom3 at juno.com>wrote:

>
> I want to write a code that allows me to input a phrase and calculate the
> number of vowels twice. once with the for loop and second with the while
> loop.I can get the for loop to work but, not the while loop. this is my code
> and response.
>
[snip]

> index = 0
> while index < len(phrase):
>    if phrase[index] in VOWELS:
>
>         index = index +1
>         print "number of vowels" ,index
>
This is an infinite loop. When phrase[index] is not in VOWELS, nothing
changes and the test "index < len(phrase)" is still true.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090908/37f9768b/attachment.htm>


More information about the Tutor mailing list