-1
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
6
  • 1
    Please edit your question and make the code a minimal reproducible example.
    – Robert
    Jun 9, 2022 at 4:24
  • It could be a problem on the line above - mismatched quotes perhaps.
    – tdelaney
    Jun 9, 2022 at 4:40
  • Updated the code section Jun 9, 2022 at 4:49
  • Could not reproduce with updated code. What version of python are you using? import sys;print(sys.version) would tell you.
    – tdelaney
    Jun 9, 2022 at 4:52
  • I have Python 3.9.12 But with the code you gave above VS shows it as 2.7.18. Thanks for pin pointing, how can I solve this ? Jun 9, 2022 at 4:59

1 Answer 1

1

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.

2
  • My Python version is 3.9.12 Jun 9, 2022 at 4:45
  • 1
    Looks like sys.version says 2.7.18 so this is a question of using the correct installed python version in vscode.
    – tdelaney
    Jun 9, 2022 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.