First day beginner to python, add to counter after nested loop

Ned Batchelder ned at nedbatchelder.com
Tue Oct 29 16:30:33 EDT 2013


On 10/29/13 4:08 PM, jonas.thornvall at gmail.com wrote:
> Why did Python not implement end... The end is really not necessary for the programming language it can be excluded, but it is a courtesy to the programmer and could easily be transformed to indents automaticly, that is removed before the compiliation/interpretation of code.

If you're going to indent your code correctly anyway, then the "end"s 
are just extra noise.  And if you aren't going to indent your code to 
match the structure, then you have two different channels of 
information: the human pays attention to the indentation, and the 
computer pays attention to the ends.  That's a recipe for creating lots 
of subtle bugs.  You get used to reading the indentation.
> They could had used print and prinln from basic? I do not want new line everytime i write out some terms. And i do not like it add extra space after each print of variable print(factor,"^2") writes out 12 ^2 and i do not think there is any space after the factor?
>

The print statement is very simple, and has not had a lot of features 
added to it, because you very quickly outgrow it anyway. If you want 
fine control over the output of your program, you use string formatting, 
for example with the .format() method on strings.

--Ned.



More information about the Python-list mailing list