print odd numbers of lines from tekst WITHOUT space between lines

alister alister.ware at ntlworld.com
Sat Feb 18 12:59:40 EST 2017


On Sat, 18 Feb 2017 11:55:34 -0600, boB Stepp wrote:

> On Sat, Feb 18, 2017 at 11:38 AM, TTaglo <tfente at gmail.com> wrote:
>> i = 1 f = open ('rosalind_ini5(1).txt')
>> for line in f.readlines():
>>     if i % 2 == 0:
>>         print line
>>     i += 1
>>
>>
>> How do i get output without breaks between the lines?
> 
> If you use "print line," (Note the trailing comma.), this should
> suppress the line break that the print statement normally inserts.
> 
> Another suggestion might be to use enumerate() instead of using a manual
> counter in your for loop.
> 
> HTH!

or simply strip the cr/lf of the end of each line



-- 
Smell from unhygenic janitorial staff wrecked the tape heads



More information about the Python-list mailing list