Why do I get an error with print(f"({x}, {y})")?

Question:

for x in range(5):
  for y in range(3):
    print(f"({x}, {y})")

I was trying to follow along in a python mastery class but I kept getting the following error.

     File "c:Users███DesktopPy ProductsTutorialHelloWorldapp.py", line 3
    print(f"({x}, {y})")
                      ^
SyntaxError: invalid syntax
Asked By: Leo Paradise

||

Answers:

you are trying to format the string while printing so you can use

for x in range(5):
  for y in range(3):
    print('{}, {}'.format(x, y))
Answered By: Abdusalam mohamed
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.