Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Strings as Comments

  • '''

marks single line comments.

There are no real multi-line comments in Python, but we can use triple-quots to create multi-line strings and if they are not part of another statement, they will be disregarded by the Python interpreter. Effectively creating multi-line comments.

print("hello")

'A string which is disregarded'

print(42)

'''
  Using three single-quotes on both ends (a triple-quoted string)
  can be used as a multi-line comment.
'''

print("world")