Is it possible to print a list with a string?

I have a list with the following values: ["hello", "world", "new", "life", "good"]. What I want to do is print the string along with the list like: My List values are: ["hello", "world", "new", "life", "good"].

I tried using inspect mylist. However, this adds backslashes to the list: "My List values are: [\"hello\", \"world\", \"new\", \"life\", \"good\"]".

Can someone guide me please? If there isn’t any perfect solution to this, can someone guide me as to how we can remove the backslashes? String.replace isn’t working for me.

If you print the string with e.g. IO.puts/2, the escape characters should be gone:

iex> list = ["hello", "world", "new", "life", "good"]
["hello", "world", "new", "life", "good"]
iex> string = "My List values are: #{inspect(list)}"
"My List values are: [\"hello\", \"world\", \"new\", \"life\", \"good\"]"
iex> IO.puts(string)
My List values are: ["hello", "world", "new", "life", "good"]
:ok
1 Like