2. First error message¶
Uppercase and lowercase letters are different
print()
is different fromPrint()
>>> Print ("hello world!")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Print' is not defined
Now try it on your own!
If we don’t use quotation marks, the computer will interpret our message as a Python command, generating a syntax error
"hello world"
is different fromhello world
>>> print (hello world)
File "<stdin>", line 1
print (hello world)
^
SyntaxError: invalid syntax
Now try it on your own!
In the Python version we’re using (Python 3), parentheses are not optional when using
print()
print("hello world")
is different fromprint "hello world"
>>> print "hello world"
File "<stdin>", line 1
print "hello world"
^
SyntaxError: missing parenthesis in call to 'print'
Now try it on your own!
Initial spaces have a meaning in Python that we’ll see later on, in this case it generates a syntax error again
These spaces are called indentations
>>> print("first message!")
File "<stdin>", line 1
print "hello world"
^
SyntaxError: unexpected indent
Now try it on your own!
You have attempted of activities on this page