Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (Retired) Ins & Outs Blocks In Python

Why is it the case that the answer to the quiz question "What symbol marks the beginning of a block?" is the symbol ":"?

I would have thought it would have been "}" or indentation. Is this possibly a mistake?

2 Answers

":" is the symbol that marks the beginning of a block. Indentation comes on the next line, and there is never a "}".

Example:

def add_two(number_to_add_two_to):
    return number_to_add_two_to + 2

Curly braces are used for sets and dicts in Python.

They are used for blocks in some other programming/scripting languages like JavaScript.