I was working with simple if-else statements in Python when a syntax error came up with the following code.
"""
A multi-line comment in Python
"""
if a==b:
print "Hello World!"
"""
Another multi-line comment in Python
"""
else:
print "Good Morning!"
This code gives a syntax error at the "else" keyword.
The following code however does not:
"""
A multi-line comment in Python
"""
if a==b:
print "Hello World!"
#One single line comment
#Another single line comment
else:
print "Good Morning!"
Could anyone tell me why this happens? Why does the Python interpreter not allow multi-line comments between if-else statements?
Aucun commentaire:
Enregistrer un commentaire