print string+ in for loop

Kevin Kohiruimaki kevin at no.mail.com
Sun May 12 10:34:47 EDT 2002


Hi Max,

On Sun, 12 May 2002 14:21:53 GMT
"Max" <nospam at nospam.nospam> wrote:

> What would you do whit that statement? Maybe printing the letters on the
> same line? If so, try
>     print c,
> that prints the letters without outputting a new line...

For example maybe I want to pick out all the vowels from 'horse', then I
can write:

word = "horse"
vowels = ['a', 'i', 'u', 'e', 'o']

for c in word:
  if not c in vowels:
    print c+

But actually, that is not the point, I know I can do it with other ways. I
just feel a little weird why you can do

for c in word:
  print c,

but not

for c in word:
  print c+

Thanks for commenting anyway :)

Peace,
--KK



More information about the Python-list mailing list