[JAVA] Python learning basics ~ How to output (display) a character string? ~

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.

How to output (display) characters?

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.


If there is no quotation mark in Python
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?


in conclusion

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

Python learning basics ~ How to output (display) a character string? ~
[Python] How to invert a character string
[Introduction to Python] How to output a character string in a Print statement
[Python] How to expand variables in a character string
[Introduction to Python] How to split a character string with the split function
How to embed a variable in a python string
Mayungo's Python Learning Episode 6: I tried to convert a character string to a number
[Introduction to Python] How to write a character string with the format function
How to convert / restore a string with [] in python
Basics of Python learning ~ What is a string literal? ~
How to input a character string in Python and output it as it is or in the opposite direction.
How to write a Python class
[Python] How to make a list of character strings character by character
[Python] How to output a pandas table to an excel file
How to quickly count the frequency of appearance of characters from a character string in Python?
Convert to a string while outputting standard output with Python subprocess
How to make a string into an array or an array into a string in Python
Try to extract a character string from an image with Python3
How to get a string from a command line argument in python
How to extract the desired character string from a line 4 commands
[Python] How to make a class iterable
[Python] How to convert a 2D list to a 1D list
How to get a stacktrace in python
How to display python Japanese with lolipop
How to display Hello world in python
How to run a Maya Python script
python learning output
[Python] How to change character string (str) data to date (strptime of datetime)
How to write a string when there are multiple lines in python
[python] How to display list elements side by side
How to read a CSV file with Python 2/3
How to create a Python virtual environment (venv)
How to open a web browser from python
How to create a function object from a string
[Python] How to change the date format (display format)
How to create a JSON file in Python
How to generate a Python object from JSON
How to add a Python module search path
Python Note: When assigning a value to a string
How to erase the characters output by Python
How to notify a Discord channel in Python
I tried to generate a random character string
[Python] How to draw a histogram in Matplotlib
How to output "Ketsumaimo" as standard output in Python
[CentOS8] How to output Python standard output to systemd log
Lark Basics (Python, Lark to make a shell-like guy)
[Tentative] How to convert a character string to Shift_jis with kivy-ios Memo kivy v1.8.0
How to install Python
How to install python
Basics of python: Output
Parse a JSON string written to a file in Python
I want to embed a variable in a Python string
[Python] How to draw a line graph with Matplotlib
How to set up a Python environment using pyenv
How to write string concatenation in multiple lines in Python
How to write a list / dictionary type of Python3
How to build a Django (python) environment on docker
How to use Python Kivy ① ~ Basics of Kv Language ~
How to display DataFrame as a table in Markdown
How to make a Python package using VS Code
Output a character string with line breaks in PyYAML