1
$\begingroup$

How to insert multiple elements in a list?

list={1,2,3,4,5,6,7,8,9}

Output: {"X" 1,"X" 2,"X" 3,"X" 4,"X" 5,"X" 6,"X" 7,"X" 8,"X" 9}

I have the listand would like to insert a string X into each element in the list. How do I do that?

$\endgroup$

closed as unclear what you're asking by Jason B., Simon Woods, MarcoB, Mr.Wizard Feb 16 '16 at 23:28

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ How about "X" # & /@ list $\endgroup$ – PatrickS Dec 2 '15 at 12:05
  • 2
    $\begingroup$ Sorry for nitpicking: HoldForm /@ {1, 2, 3, 4, 5, 6, 7, 8, 9} "X" $\endgroup$ – Kuba Dec 2 '15 at 12:05
  • $\begingroup$ Just to add one more way: list /. x_Integer -> {"X", x} // Flatten ?? $\endgroup$ – Alexei Boulbitch Dec 2 '15 at 12:16
  • $\begingroup$ Dear NewTester4201, are missing comas intentional? $\endgroup$ – Kuba Dec 2 '15 at 13:02
  • 1
    $\begingroup$ Is it a good example of 'easy found in doc'? $\endgroup$ – garej Dec 2 '15 at 13:22

Browse other questions tagged or ask your own question.