1
votes
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

1
f-strings are a python 3 feature. Make sure you're on version 3.6+ - rdas

1 Answers

1
votes

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