A similar question with Print new output on same line, which does not answer my question.
I wonder how (with python 2 and 3) to print all to one line. e.g., By running:
print("Result of:\t")
mylist1=[]
mylist2=[]
name = "class_1"
for i in range(-5, 0):
mylist1.append(i)
for j in range(1, 6):
mylist2.append(j)
print(name+"\t")
print(mylist1+"\t"+mylist2)
What I got:
Result of:
class_1
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-100-1e34909da6d3> in <module>
10 mylist2.append(j)
11 print(name+"\t")
---> 12 print(mylist1+"\t"+mylist2)
13
TypeError: can only concatenate list (not "str") to list
However, what I want is to print them in one line separated with "\t":
Result of: class_1 [-5, -4, -3, -2, -1] [1, 2, 3, 4, 5]
which solution is usually used for this case?