This is a rather basic question but as I am new to programming, I have been stuck on it for a little while. I am trying to add strings to the beginning and end of every element in a list (each element in the list is a string).
I know to use the StringJoin or <> function to join strings individually, e.g.: "what I want to add"<>"original string"<>"what I want to add". However, I am having some trouble applying this broadly to each element in a list. I think I am supposed to use the Map or /@ function, but am simply lost at how to apply it correctly.
Here is an example:
exampleList={"apple","pear","banana","orange"}
In the beginning of each element, I want to add the string: "Is this fruit a " and in the end: "?" so that the changed list would yield:
exampleList={"Is this fruit a apple?", "Is this fruit a pear?", "Is this fruit a banana?", "Is this fruit a orange?"}
Any help would be greatly appreciated
StringTemplate["Is this fruit a ``?"] /@ {"apple", "pear", "banana", "orange"}
. $\endgroup$StringForm["Is this fruit a ``?", #] & /@{"apple","pear","banana","orange"}
for version 9 and earlier versions. $\endgroup$