Getting an "Invalid Syntax" When Trying to Perform String Interpolation

Getting an invalid syntax when trying to perform string interpolation

As suggested by Josh Lee in the comment section, that kind of string interpolation was added in Python 3.6 only, see What’s New In Python 3.6 (here it's called "PEP 498: Formatted string literals").

You, however, seems to be using Python 3.5.2, which does not support that syntax.

f-strings giving SyntaxError?

I think you have an old version of python. try upgrading to the latest version of python. F-string literals have been added to python since python 3.6. you can check more about it here

Why do I get an error with print(f ({x}, {y}) )?

you are trying to format the string while printing so you can use

for x in range(5):
for y in range(3):
print('{}, {}'.format(x, y))

Getting an invalid syntax when trying to perform string interpolation

As suggested by Josh Lee in the comment section, that kind of string interpolation was added in Python 3.6 only, see What’s New In Python 3.6 (here it's called "PEP 498: Formatted string literals").

You, however, seems to be using Python 3.5.2, which does not support that syntax.



Related Topics



Leave a reply



Submit