Reputation: 14309
I have the following input:
x = ['a', 'b', 'c']
I'd like to get the following output:
some blah blah ['a', 'b', 'c'] and blah.
I try the following but can't find a way to escape the single quotes:
f"some blah blah ['{', '.join(x)}'] and blah."
Upvotes: 1
Views: 33
Reputation: 14949
You can use
x = ['a', 'b', 'c']
print(f"some blah blah {x} and blah.") # will print "some blah blah ['a', 'b', 'c'] and blah."
print(f"some blah blah [{', '.join(x)}] and blah.") # will print "some blah blah [a, b, c] and blah."
Upvotes: 1