Very simple Python question

Started by
2 comments, last by smr 18 years ago
Hello, Sorry for wasting your time but I'm just curious...

counter = 0
while counter <= 10
  print counter
  counter += 1
Why is each number printed on a new line?! I haven't specified anything to actually do it. Cause you see, when I was initially writing this, I actually tried to implent it. Before that, though, I simply tested if all the code was working properly. Not only was it working properly, but all the numbers were printed on a new line. Is it built-in or something? Then how do I print all the numbers on the same line? Thanks!
Advertisement
http://docs.python.org/ref/print.html
Quote:A "\n" character is written at the end, unless the print statement ends with a comma. This is the only action if the statement contains just the keyword print.
Aye, it's built-in. Sorry, didn't know that. Are all prints like that? Is the PHP one like that, too? Anyways, sorry for being so stupid.
Quote:Original post by Huffer
Aye, it's built-in. Sorry, didn't know that. Are all prints like that? Is the PHP one like that, too? Anyways, sorry for being so stupid.


Not stupid. You just didn't know.

Python is python and perl is perl. Any simularities are only circumstantial.

This topic is closed to new replies.

Advertisement