2
$\begingroup$

I want to place quotations for every element in a list. I am trying this

col = Table["\"" i "\"", {i, 0, 5}];

and I am getting

{0, ("\"")^2, 2 ("\"")^2, 3 ("\"")^2, 4 ("\"")^2, 5 ("\"")^2}

instead of

{"0", "2", "3", "4", "5"}

How should I correct it?

Thank you.

$\endgroup$
1
  • 2
    $\begingroup$ Use ToString and StringJoin : Table["\"" <> ToString[i] <> "\"", {i, 0, 5}]. Voting to close. $\endgroup$ Commented Jun 4, 2020 at 19:21

1 Answer 1

1
$\begingroup$
col = Table["\"" <> ToString@ i <> "\"", {i, 0, 5}]
{"0","1","2","3","4","5"}

Alternatively, you can use IntegerString:

IntegerString @ Range[0, 5]
{"0", "1", "2", "3", "4", "5"}
$\endgroup$
2
  • $\begingroup$ Thank you so much @kglr $\endgroup$ Commented Jun 4, 2020 at 19:22
  • $\begingroup$ @GauravMaurya, you are most welcome. $\endgroup$
    – kglr
    Commented Jun 4, 2020 at 19:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.