f-strings giving SyntaxError?
f-strings were added in python 3.6. In older python versions, an f-string will result in a syntax error.
If you don't want to (or can't) upgrade, see How do I put a variable inside a String in Python? for alternatives to f-strings.
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
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.
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