[Tutor] Differentiating vowels from consonants
William Becerra
wbecerra1 at gmail.com
Sun Oct 26 10:01:52 CET 2014
Hello, I'm new to programming
Running Python 2.7.8 on Windows 8 OS
I was reading http://www.sthurlow.com/python/lesson07/
Here there is an example of the for loop with a Cheerleader
program but the program is not able to print grammatically correct.
word = raw_input("Who do you go for? ")
for letter in word:
call = "Gimme a " + letter + "!"
print call
print letter + "!"
print "What does that spell?"
print word + "!"
I tried changing the code so that the program
can recognize vowels from consonants and write the correct article (a or an)
here is my code.
word = raw_input("Who do You Support: ")
vowels = ('a', 'e', 'i', 'o', 'u')
for letter in word:
if letter == vowels:
call = 'Give me an ' + letter + '!'
print call
print letter + '!'
else :
call = 'Give me a ' + letter + '!'
print call
print letter + '!'
print 'What does that say'
print word + '!!'
My code also isn't able to recognise vowels.
For example if i write Manchester as the raw_input
i get :
give me a M
give me a a
etc.
I would like it to say
give me a M
give an a
So here is my question. What is wrong with my code and how can I
change it to get the result I want.
Thank You
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141026/e8a00922/attachment-0001.html>
More information about the Tutor
mailing list