I hope this is not another embarrassingly obvious answer to a simple question.

Python 3, under Kubuntu.

xrange() fails whereas range() is accepted. Could this be an installation problem?

phil@Asus:~/Python$ python3
Python 3.4.2 (default, Oct  8 2014, 13:18:07)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> for row in xrange(0,12):
...     print(row)
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'xrange' is not defined
>>>

Under IDLE 3:

for row in xrange(0,12):
    print('test ',row)

xrange() is accepted but prints the following:

('test ', 0)
('test ', 1)
('test ', 2)
('test ', 3)
('test ', 4)

Whereas it should be printed as:

test 0
test 1
etc

Could this be another Python 3 installation problem, this time with print()?

Under the Python 3 interpreter using range() and not xrange() the printout is correct.

--
Regards,
Phil
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to