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 (2015) Python for Beginners Syntax and Style

Indentation

So I'm curious about the indentation. Is it required for the code to compile properly? Or is it purely for visual effect?

I.e if we have

def function():
print("hello)

would that be identical to

def function():
    print("hello)

2 Answers

Short answer: white space matters, in Python.

The why, would take a bit more explanation and I am feeling lazy so read here: "What is Python Whitespace and how does it work?"

That's what Kenneth seemed to be implying. Thanks for the clarification and link. Cheers

alan ingram
PLUS
alan ingram
Courses Plus Student 3,979 Points

No the two are not the same. If you use IDLE it will indent your second line for you so you wont even be able to input it incorrectly.