I picked up The Absolute Beginners Guide to Programming with Python and started to work through it. I'm stuck on a problem that deals with a while loop. You're suppose to count the vowels in an entered phrase twice (once with for loop and again with while loop), then output the numbers. I have the for loop working, but I appear to not be ablt to understand how to get it working with the while loop. I have included the code below. Any help will be appreciated.
count = 0
word = raw_input("Please enter a phrase: ")
for letter in word:
if letter in "aeiou":
count +=1
else:
print "The number of vowels are: ", count
raw_input("Press the enter key to contniue")
phrase = raw_input("Please enter a second phrase: ")
count = 0
VOWEL = "aeiou"
while count < len(phrase):
for letter in word:
letter = phrase[count]
count = count +1
print "The number of vowels in your second phrase are: ",letter
Question
jackeye
I picked up The Absolute Beginners Guide to Programming with Python and started to work through it. I'm stuck on a problem that deals with a while loop. You're suppose to count the vowels in an entered phrase twice (once with for loop and again with while loop), then output the numbers. I have the for loop working, but I appear to not be ablt to understand how to get it working with the while loop. I have included the code below. Any help will be appreciated.
count = 0
word = raw_input("Please enter a phrase: ")
for letter in word:
if letter in "aeiou":
count +=1
else:
print "The number of vowels are: ", count
raw_input("Press the enter key to contniue")
phrase = raw_input("Please enter a second phrase: ")
count = 0
VOWEL = "aeiou"
while count < len(phrase):
for letter in word:
letter = phrase[count]
count = count +1
print "The number of vowels in your second phrase are: ",letter
Thanks,
Jackeye
Link to comment
Share on other sites
6 answers to this question
Recommended Posts