The join command works fine, but when you print the string, it cares about special characters so puts a new line whenever encounter to \n
.
But you can change the print behavior to escape special characters like this:
Use repr:
a = "Hello\tWorld\nHello World"
print(repr(a))
# 'Hello\tWorld\nHello World'
In your source code it would be like:
list_str = ["first_string", "\nsecond_string"]
join_str = ",".join(list_str)
print(repr(join_str))
Output:
first_string,\nsecond_string
solved How join a list of raw strings? [closed]