Oct-28-2016, 08:27 AM
(Oct-26-2016, 06:23 AM)diemildefreude Wrote:(Oct-26-2016, 03:44 AM)Larz60+ Wrote: the 2nd print statement will simply print a end of line.
since the loop is not doing this, the effect is to finish the line of the loop,
not and extra line.
if you change it to print some text you will see this (at the end of the loop print on same line)
Ah, I think I see the problem. the last print is not related to the loop, so it's processed as an error if you enter it in the ... at the end of the loop statement. But in a script, it's perceived as a new statement.
this seems to be the case, not specific to print
Output:lt1/forums /home/forums 12> py2
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> i = 1
>>> while i <= 6:
... i += 1
... x = i
File "<stdin>", line 3
x = i
^
SyntaxError: invalid syntax
>>>
lt1/forums /home/forums 13> py3
Python 3.5.2 (default, Sep 10 2016, 08:21:44)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> i = 1
>>> while i <= 6:
... i += 1
... x = i
File "<stdin>", line 3
x = i
^
SyntaxError: invalid syntax
>>>
lt1/forums /home/forums 14>

Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.