Unlike C++ cout <<
, Python print()
function prints the passed arguments with an endline/newline and sometimes I found it annoying having multiple lines in terminal.
I know I can use the print(var1, end='')
or sys.stderr.write()
from sys library but it's too long and quite hard to read.
What I think is that may be I can make a cout<<
operator in python and prints variables or values without new line at the end
# Example in Python:
for x in range(3):
print(x)
# Output:
0
1
2
# In C++:
for (int x = 0; x < 3; x++){
cout << x << ' ';
}
# output:
0 1 2
Also, '<<' is much easier to type because the key is in the lower portion of the keyboard unlike parenthesis.