SyntaxError: check why invalid syntax appears

Asked 2 years ago, Updated 2 years ago, 100 views

After you push the computer once and install Python, I just used print, but there's an error What should I do? Should I reformat my computer?

>>> print "hello World"
  File "<stdin>", line 1
    print "hello World"
                      ^
SyntaxError: invalid syntax

syntax python syntax-error

2022-09-22 22:15

1 Answers

Before that, I think you used Python 2.x and installed 3.x while installing it.

From python3, print is a function, so it must be parentheses like other functions.

print("Hello World")

Change it all to 3 this time, install python 2 together, or erase 3 and reinstall 2.


2022-09-22 22:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.