Home > Mobile >  I get "SyntaxError: invalid syntax" for no reason (I think)
I get "SyntaxError: invalid syntax" for no reason (I think)

Time:10-22

this is the code print(f"{DataBase.Count()} Users\n") and this is the error

    print(f"{DataBase.Count()} Users\n")
                                      ^
SyntaxError: invalid syntax

and i dont know how to fix it please help me

CodePudding user response:

If you want to use fstring in python 2.7, you could use this lib: https://github.com/asottile-archive/future-fstrings

fstring is added after python 3.6.

CodePudding user response:

You are trying to run Python 3 (in fact Python >= 3.6) in Python 2.7.

The Python 2.7 version of this code would be:

    print "{} Users\n".format(DataBase.Count())

But what you should really do is upgrade to Python 3. The method will vary depending on whether you are on Linux/Mac/Windows. Google "upgrade Python 2 to 3 [your operating system name here]".

  • Related