On 04/27/2013 05:02 AM, Mariel Jane Sanchez wrote:
I was in Seattle for 4 days for our band trip so i miss some classes.
Chapter 4
Project 1
"Write a program that asks for a phrase, and then calculates and displays the number of vowels in the phrase, twice. The first time, your program should calculate the number of vowels in the phrase using a for loop. The second time, your program should use a while loop."
My code:
phrase = raw_input("Please enter a phrase: ")
VOWELS = "aeiou"
new = ""
for letter in phrase:
    if VOWELS in phrase :
        print newv
It keeps printing the phrase not the new string. How would you do this? And what am i doing wrong?
I'll take a crack at your first problem ...

Not sure what newv is - it doesn't seem to be defined anywhere but is called in the print statement.

In pseudocode aren't you doing something like this?

Get a phrase from the user.
Loop over the phrase looking for letters that match the letters in VOWELS string.
Print any matches you find.

Looks like you are getting the phrase OK, setting your vowels string OK, looping over the phrase OK then looking to see if the VOWELS string is part of the phrase - is that what you mean to do?

Keep at it, you are getting there!

thomas
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to