[Tutor] Getting range of a list
ilhs_hs at yahoo.com
Wed Feb 6 00:59:39 CET 2013
Sorry for html formatting. Honestly I don't know how to shut html formatting off in Yahoo. I don't have options for send in ('Tools|Options|''send''missing').
From: Dave Angel <davea at davea.name>
To: tutor at python.org
Sent: Tuesday, February 5, 2013 5:20 PM
Subject: Re: [Tutor] Getting range of a list
On 02/05/2013 04:48 PM, Hs Hs wrote:
> Thanks Steve.
> But one question, when I print, I get extra empty lines. How to get rid of them! Thanks again.
>>>> f = open('test')
>>>> head = '---'
>>>> for line in f:
line = line.rstrip() #get rid of the trailing newline (and any other
> if line.startswith('>'):
> head = line[1:].strip()
> print head+'\t'+line
The print generates a newline by default. So you either have to do the
strip() I suggested above, or use a trailing comma on the print. I
recommend the former.
You're still posting using html mail. And your indentation is still
getting messed up. Also, you top-posted.
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor