Here, I would like to describe a memorandum of Python learning and a comparison with Ruby and JavaScript. We hope that it will be helpful for beginners in programming and those who are also interested in other languages.
common part The character string must be enclosed in either single-byte "''" single quotation marks or "" "" double quotation marks. Note that an error will occur if there is no description! Python
script.py
print('Hello World')
Ruby
index.rb
puts 'Hello World'
JavaScript
script.js
console.log('Hello World');
The sentence ends with a ";" semicolon.
SyntaxError: invalid syntax
I get the error "Syntax error: Invalid syntax".
And, in the future, as the number of descriptions increases, the probability that the above error will occur will also increase, so in that case, check the following.
--Are you typing the wrong name for a Python command or function? --Did you forget to close the parentheses? -Isn't the half-width space full-width? --Did you forget to write ":" for for statement, if statement, function, etc.? --Did you forget the "''" single quotes or the "" "" double quotes?
I have just started learning "Python", so I look forward to working with you! Please do not hesitate to point out any mistakes! !!
Reference article What is SyntaxError: invalid syntax?
Recommended Posts