I am using the below code in python to print the values in the list in a single row, but it prints everything in a new line.
for abc in values:
print ','.join(abc)
Desired output:
S,t,r,e,e,t
N,o
Y,e,s
I am using the below code in python to print the values in the list in a single row, but it prints everything in a new line.
for abc in values:
print ','.join(abc)
Desired output:
S,t,r,e,e,t
N,o
Y,e,s
I assume you are using python 2. If this is the case, you can add a trailing comma after your print statement:
>>> for abc in ['street','No', 'Yes']:
... print ','.join(abc),
...
s,t,r,e,e,t N,o Y,e,s
If you were using Python 3, you can then use the extra argument end
in the print function:
>>> for abc in ['street','No', 'Yes']:
... print(','.join(abc), end='')
...
s,t,r,e,e,tN,oY,e,s>>>
Note that this does not include a trailing new line.
The Python 3 method can be accomplished in Python 2 by inserting from __future__ import print_statement
in the first line of your program.