How can I debug this Python syntax error with f string

Question:

def write_users_group(heading_writer, heading, user_writer, users):

    heading_writer.writerow([f"{heading}", f"{len(users)} users"])
    user_writer.writeheader()
    for user in users:
        user_writer.writerow(user)
    heading_writer.writerow([" "])

Error:

File "/Users/ashirwadniv/Downloads/gitlab/users.py", line 59

heading_writer.writerow([f"{heading}", f"{len(users)} users"])
                                    ^
SyntaxError: invalid syntax
Asked By: Ashirwad.nivalkar

||

Answers:

This syntax is only allowed for Python version 3.6 and above. Check/Upgrade your Python version.

Fyi, there is nothing wrong with your syntax provided the python version supports it.

Answered By: Beast
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.