f-strings giving SyntaxError? f-strings giving SyntaxError? python python

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


This is a python version problem.

Instead of using

print(f"Let's talk about {my_name}."

use

print("Let's talk about {}.".format(my_name))

in python2.

Your code works on python3.7.

Check it out here:

my_name= "raushan"print(f"Let's talk about {my_name}.")

https://repl.it/languages/python3


Python Interpreter causes the following issue because of the wrong python version you calling when executing the program as f strings are part of python 3 and not python 2. You could do this python3 filename.py, it should work. To fix this issue, change the python interpreter from 2 to 3.