What is the equivalent in Python 3 to the following Python 2 code:

# -----------------------------
for i in range(5):
    print i,
# -----------------------------

?

Be careful that the above code doesn't add a trailing space after the last number in the list, hence the following Python 3 code isn't strictly equivalent:


# -----------------------------
for i in range(5):
    print(i, end=' ')   # <- The last ' ' is unwanted
print()
# -----------------------------
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to