[Tutor] (no subject)
shellcom3 at juno.com
shellcom3 at juno.com
Tue Sep 8 15:48:05 CEST 2009
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.
#demo for loop, and while loop
phrase = raw_input("enter your phrase:")
VOWELS = "aeiou"
number = 0
for letter in phrase:
if letter.lower() in VOWELS:
number = number +1
else:
pass
print "Number of vowels =",number
raw_input("Press the enter key to continue.")
index = 0
while index < len(phrase):
if phrase[index] in VOWELS:
index = index +1
print "number of vowels" ,index
enter your phrase:tell me your name
Number of vowels = 0
Number of vowels = 1
Number of vowels = 1
Number of vowels = 1
Number of vowels = 1
Number of vowels = 1
Number of vowels = 2
Number of vowels = 2
Number of vowels = 2
Number of vowels = 3
Number of vowels = 4
Number of vowels = 4
Number of vowels = 4
Number of vowels = 4
Number of vowels = 5
Number of vowels = 5
Number of vowels = 6
Press the enter key to continue.
____________________________________________________________
Best Weight Loss Program - Click Here!
http://thirdpartyoffers.juno.com/TGL2141/fc/BLSrjpTFoYcWEqYCcbHEaFPTq8jdS8V2cC4YnTjQIbcZlB9fvaKI0BwmgT2/
More information about the Tutor
mailing list