1 | initial version |
Sage uses Python 2.7. You can add a comma at the end of your print statement to avoid a newline.
However you will still get a space, and I don't know how to avoid that.
sage: for a in [1, 2, 3]: print a,
1 2 3
One workaround is to build a string incrementally, and only print it when it's done.
sage: s = ''
sage: for a in [1, 2, 3]: s += str(a)
sage: print s
123
2 | No.2 Revision |
Sage uses Python 2.7. You can add a comma at the end of your print statement to avoid a newline.
However you will still get a space, and I don't know how to avoid that.
sage: for a in [1, 2, 3]: print a,
1 2 3
One workaround is to build a string incrementally, and only print it when it's done.
sage: s = ''
sage: for a in [1, 2, 3]: s += str(a)
sage: print s
123
The migration to Python 3 is tracked here:
http://trac.sagemath.org/ticket/15530
3 | No.3 Revision |
Sage uses Python 2.7. You can add a comma at the end of your print statement to avoid a newline.
However you will still get a space, and I don't know how to avoid that.
sage: for a in [1, 2, 3]: print a,
1 2 3
One workaround is to build a string incrementally, and only print it when it's done.
sage: s = ''
sage: for a in [1, 2, 3]: s += str(a)
sage: print s
123
The For other workarounds, searching the web for "python print without newline or space"
yields a number of results among which:
Note: the migration of SageMath to Python 3 is tracked here:
http://trac.sagemath.org/ticket/15530
4 | No.4 Revision |
Sage uses Python 2.7. You can add a comma at the end of your print statement to avoid a newline.
However you will still get a space, and I don't know how to avoid that.space:
sage: for a in [1, 2, 3]: print a,
1 2 3
One workaround is to build a string incrementally, and only print it when it's done.
sage: s = ''
sage: for a in [1, 2, 3]: s += str(a)
sage: print s
123
For other workarounds, searching the web for "python print without newline or space" yields a number of results among which:
In particular you can get the Python3-like print function:
sage: from __future__ import print_function
sage: for a in [1, 2, 3]:
....: print(a, end='')
....: print('')
123
Note: the migration of SageMath to Python 3 is tracked here:
http://trac.sagemath.org/ticket/15530