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 trialwpnawzshaq
861 Pointsfor loop is not block!
In this video, you have said that for loop is a block, and in Python for Beginners section of Python Basics course in video Syntax and Style you said that block is what is beneath(and indented) for loop or function. What is block?
1 Answer
Beshoy Megalaa
3,429 PointsA block(also known as code block) is a section of code grouped together. In Python a block is indicated by indention.
# This is a code block
if True:
# statement here
# another statement
# This is a code block
for x in range(10):
# statement here
# another statement
# This is a code block
while True:
# statement here
# do something
# statement here, but is not part of code block since it is unintended
You can also have a block with a block.