Reputation: 275
In Jupyter Notebook my Code runs fine, but when I run it from shell i get a syntax error at this part of my code:
res = f'"x"'+" "+f'"y"'+" "+f'"t"'+" "+f'"id"'+" "+f'"id2"'
^
SyntaxError: invalid syntax
However I need the String res
to look like:
""x" "y" "t" "id" "id2""
I guess that the way i create it is causing the error.
Is there any other way to create a String containing quotation marks? Or anything to get rid of the syntax error? Thanks!
Upvotes: 0
Views: 1211
Reputation: 12015
f-strings, or formatted string literals is supported only from python 3.6. If you are using old version of python, try to upgrade. If you have both python2 and python3 installed, make sure you are launching python3
But for the output you expect, you dont need f-strings
res = '"x" "y" "t" "id" "id2"'
Upvotes: 1
Reputation: 275
Got the answer now:
res= "\"x\" \"y\" \"t\" \"id\" \"id2\""
works for Shell as well as Python
Upvotes: 0