PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, December 11, 2022

[FIXED] How can I debug this Python syntax error with f string

 December 11, 2022     f-string, python, syntax     No comments   

Issue

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

Solution

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
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing