-2
name = 'peace'
age = 21
print(f"your name is {name} and your age is {age}")

error File "", line 1 f"your name is {name} and your age is {age}."

SyntaxError: invalid syntax

Bill Hileman
  • 2,798
  • 2
  • 17
  • 24

1 Answers1

1

If your Python version is older than 3.6 you can not use f-strings because they are added in Python 3.6, but you can use "{}".format(something)

name = 'peace'
age = 21
print("your name is {} and your age is {}".format(name,age))

Also see: PEP 3101 -- Advanced String Formatting

Yagiz Degirmenci
  • 16,595
  • 7
  • 65
  • 85
  • 1
    Thanks for this -- just set up with a Synology DiskStation, and its Python 3 is 3.5.1, and was tearing my hair out trying to figure out how to "downgrade" an f-string so it works in 3.5. – JeanSibelius Oct 14 '20 at 09:58