[Tutor] Newbie question

Lee Cullens leec03273 at mac.com
Tue Apr 19 06:37:54 CEST 2005


Thank you Brian for making the point that I did such a poor job of 
conveying.  My post did indeed fail to clearly and concisely answer the 
question.

Lee C


On Apr 18, 2005, at 11:34 PM, Brian van den Broek wrote:

> Lee Cullens said unto the world upon 2005-04-18 21:07:
>> That just gives you a spacer line after your output. To see such as a 
>> separator change it to   print '*'*10
>> On Apr 18, 2005, at 8:55 PM, Hoffmann wrote:
>>> Hi All:
>>>
>>> I am a newbie, and I am enjoying to study Python a
>>> lot. I have a question about an example I got from one
>>> of my books.
>>> The program is:
>>>
>>> def square(y):
>>>    return y * y
>>>
>>> for x in range(1, 11):
>>>    print square(x),
>>>
>>> print
>>>
>>> Well, I understood the code above. My question is: Is
>>> it really necessary I have the last "print" statment
>>> (last line) in the code?
>>> Thanks a lot in advance.
>>> Hoffmann
>>
>
> Hi all,
>
> in the particular case, it is more than just a spacer, I think. It 
> serves to break the "print on the same line" feature of the
> print some_thing,
> statement in the loop. Without it, the next thing printed will be on 
> the same line:
>
> >>> for i in range(1):	# contrived to keep it all in block construct
> ... 	for i in range(5):
> ... 			print 'in',
> ... 	print 'out'
> ...
> in in in in in out
>
> (Unless, of course, that is what Lee meant. In which case--nevermind 
> :-)
>
> Best,
>
> Brian vdB
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>



More information about the Tutor mailing list