print odd numbers of lines from tekst WITHOUT space between lines
boB Stepp
robertvstepp at gmail.com
Sat Feb 18 12:55:34 EST 2017
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!
--
boB
More information about the Python-list
mailing list