why not?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Jan 21 06:37:25 EST 2013
On Mon, 21 Jan 2013 11:02:10 -0600, kwakukwatiah wrote:
> f = open(r'c:\text\somefile.txt')
> for i in range(3):
> print str(i) + ': ' + f.readline(),
>
> please with the print str(i) + ‘: ‘ + f.readline(),
> why not print str(i) + f.readline(),
Because the output will be different. The first code will print:
0: first line
1: second line
2: third line
The second code will print:
0first line
1second line
2third line
You should really try these things and see what they do before asking.
--
Steven
More information about the Python-list
mailing list