Skip to main content
Formatted code
Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 197

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 Lists 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!

So in 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 the following does what you need (and works for any number of Lists of elements):

a = {1}; b = {2, 3};

str = StringRiffle[Join[a, b], ", "]

Yields

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 String.

Hope this helps!

In 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.

The following does what you need (and works for any number of Lists of elements):

a = {1};
b = {2, 3};

str = StringRiffle[Join[a, b], ", "]

Yields

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 String.

Hope this helps!

Source Link
enano9314
  • 543
  • 4
  • 9

So in 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 the following does what you need (and works for any number of Lists of elements):

a = {1}; b = {2, 3};

str = StringRiffle[Join[a, b], ", "]

Yields

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 String.

Hope this helps!