0

f"python str {var}" doesn't work

var = "str" print(f"this is a {var}") gives a syntax error . How to use the f"{}" string formatting ?

10th Mar 2018, 7:05 AM
Ahamed Shibili
Ahamed Shibili - avatar
3 Respuestas
+ 7
f-string is new in Python 3.6. Unfortunately, SoloLearn is still using Python 3.5. This works: var = "str" print("this is a {}".format(var)) https://www.python.org/dev/peps/pep-0498/
10th Mar 2018, 11:04 AM
David Ashton
David Ashton - avatar
0
did you get?
11th Mar 2018, 8:27 PM
Soulieman Khater Abdourasoul Tabit
Soulieman Khater Abdourasoul Tabit - avatar
0
The problem was with the Python version
28th Mar 2018, 10:31 AM
Ahamed Shibili
Ahamed Shibili - avatar