I've ran this code using Python 3.4.1 and it works, but if I use Python 2.7.8 it fails, why?
i=1
while i<10:for x in(1,2,3,4,5,6,7,8,9):print (i*x,'\t',end='')if x==9: print('\n')i=i+1
I've ran this code using Python 3.4.1 and it works, but if I use Python 2.7.8 it fails, why?
i=1
while i<10:for x in(1,2,3,4,5,6,7,8,9):print (i*x,'\t',end='')if x==9: print('\n')i=i+1
In fact, print
is a function in Python 3 but not Python 2. In Python 2, you need to remove ()
and end
. As an alternative, you can add from __future__ import print_function
into your code in Python 2 to use print
as in Python 3.