So inIn this case you are printing the InputForm
of whatever expression you give to Print
. So if you want to print the String
"1, 2, 3"
then you will need to construct that String
to print.
So theThe following does what you need (and works for any number of List
s of elements):
a = {1}; b = {2, 3};
str = StringRiffle[Join[a, b], ", "]
a = {1};
b = {2, 3};
str = StringRiffle[Join[a, b], ", "]
Yields
1, 2, 3
1, 2, 3
And if you want to Print
this (which may not be the right tool in the first place depending on what you want to do), then you can just
Print[ str ]
and it will do what you want.
The idea is to join the lists together and then separate them by commas as a StringString
.
Hope this helps!