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
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.
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
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.