Printing
Printing
print("Hello world")
The reason you were able to see the words appear is because of the print
command. Change your code to look like this and run it again.
"Hello world"
Printing
Newline Character
The print command automatically adds a newline character each time you
use it. This is the default behavior. The code below will not print the two
words on the same line. Enter the code below (or copy/paste the code) and
click the TRY IT button.
print("Hello")
print("world")
Newline Character
The text in red shows the newline character which is added even if you do
not type it. (The newline character is what is inserted when you press
“Enter” or “Return”).
Comments
You may have wondered why a couple of lines of code are a different color
(in the below example, light brown, but it depends on the Theme you have
picked):
.guides/img/comments
In Python, to write notes in code without effecting it’s function we can use #
to make a comment.
Comments can also be used to help you fix your code. You can “comment
out” lines of code that are not working or you suspect are causing
problems.
challenge
Comment Blocks
To make a multi-line comment you can either combine the single line
characters # or wrap the set of lines in triple quotes (''').
'''
This is a multi-line comment
You can then easily end the comment with a triple quote (see
below)
'''
What is an IDE?