• 0

Python Help Needed


Question

Hi everybody, i am trying to make a while loop that will display the vowels in a sentence

for example:

VOWELS = "aeiouAEIOU"

counter = 0

phrase = raw_input("Enter a phrase. ")

THIS WILL BE PSUDOCODE FROM HERE ON OUT

while there are letters in a phrase

-------check to see if they are in VOWELS

--------if VOWELS in phrase

-------------counter += 1

print "There are", counter, "vowels in your sentence"

-I'd really appreciate the help, I am running version 2.5.3 for my class. My project is already late, but still needs to be done. Thank you in advance.

Edited by Kudos
Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0
looks all right to me. You just need to make sure you implement your pseudo-code correctly.

Might I suggest projecteuler.net/ to help you learn a new language

I was actually hoping that someone could type in the coding for me, i've honestly been trying to get this to work for over 4 hours. So pathetic for such a small code.

Link to comment
Share on other sites

  • 0
I was actually hoping that someone could type in the coding for me, i've honestly been trying to get this to work for over 4 hours. So pathetic for such a small code.

If your in college maybe you should reconsider your degree path; at the very least you need to sit back and take a look at whats got you to this point. If someone was just to type up this simple code for you what would you have learned? If your teacher questions you on a particular aspect of the code what are you going to say?

Stop searching the internet for the "answer"; start searching the internet for the tools YOU need for the answer.

Link to comment
Share on other sites

  • 0
I was actually hoping that someone could type in the coding for me, i've honestly been trying to get this to work for over 4 hours. So pathetic for such a small code.

have you looked at the regular expressions module of python. just use regex to group the voewls and print the length ... that should do it.

Link to comment
Share on other sites

  • 0

It's entirely normal to spend a ridiculous amount of time working out the simplest programs when you begin. On average I probably spent 10 hours on each C++ homework when I took that class.

Here, most of the work is already done since you are provided with a correct algorithm. It translates almost directly into Python. You just need to get the syntax correct; you should have a proper textbook to help you with that. I can recommend "Core Python Programming" if you don't have one.

If you have any question more specific than "please provide the answer to my homework question", you'll certainly get more helpful replies.

Link to comment
Share on other sites

  • 0

Wouldn't it be easier to iterate through the phrase?

for char in phrase:
	if char == a vowel
	counter = counter + 1

print counter, " number of vowels in phrase"

You'll have to work out the matching the char with the vowel (there's ugly and easy ways of doing that)

Link to comment
Share on other sites

  • 0

To the OP, what you need to do is find a good tutorial/book.

You then find the section about while loops, read it and apply it. May be copy and try out their code and exercises first to develop some familiarity (this helps me with spotting missing semi-colons and brackets and the like).

Link to comment
Share on other sites

  • 0

I actually had everything right except for the counter....that's why i wanted someone else to type in what they thought the code was. My counter (when i typed it in) was wrong, i did not have a counter for the length of the letters and a counter for adding 1 when vowels were in the letters.

so yeah, 2 counters were my problem.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.