Name

: (Colon)

Examples
def exclaim(s, count): # A colon declares the start of an indented block.
  return s + ("!" * count)

# Any statements followed by indented lines should end with a colon.
for i in range(1, 6):  # And here
  print(exclaim("Python", i))
# Separates key/value pairs
element_names = {'H': 'hydrogen', 'He': 'helium', 'Li': 'lithium'}
print(element_names['H'])
Description A colon declares the start of an indented block. Any statement followed by an indented block of code should end with a colon. The colon also separates key/value pairs in dictionary literals.
Related if
else
for
def
Dictionary

Updated on Tue Feb 27 14:07:12 2024.

If you see any errors or have comments, please let us know.