If you use the print function, it doesn't run as you want, and you get an error called SyntaxError: invalid syntax.python
It seems that it is difficult to understand because the occurrence of the error has changed since it is in the Google collaboration environment.(Actually, the reason seems to be the number of Python versions used in the environment.→See postscript)
This is due to the absence of the closing parenthesis
) of the previous line, not the line pointed out as SyntaxError in Google Collaboration as stated in the comment.
This is the code if you shorten it to the smallest part that the problem reproduces.
If you reproduce the appearance in the Google Collaboration environment in text, you will see an error like this:
SEARCH STACK OVERFLOW
The command prompt on the local PC looks like this and points out the problem directly.
Recognize that the Google Collaboration environment may display errors when they are out of alignment with those issues, and be careful not to see any problems around them.
@mjy pointed out that the reason is not because of the Google collaboration environment, but because of the difference in the number of Python versions.
Currently, Python is 3.7.13 for Google collaboration.
When I tried running Python in the 3.9.13 environment at the local PC command prompt, I got the same error as the question.
This means that everything under Python 3.10 series, regardless of the Google Collaboration environment, is affected and needs to be careful.
© 2022 OneMinuteCode. All rights reserved.