By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,696 Members | 1,396 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,696 IT Pros & Developers. It's quick & easy.

Indented block error

P: 3
I could understand yet what indent mean, how to write a block of code in example.

IndentationError: expected an indented block
Expand|Select|Wrap|Line Numbers
  1. >>> for letter in 'Python':     # First Example
  2. ...  if letter == 'h': 
  3. ... print letter
  4.   File "<stdin>", line 3
  5.     print letter
  6.     ^
  7. IndentationError: expected an indented block
Oct 5 '12 #1
Share this Question
Share on Google+
1 Reply

bvdet
Expert Mod 2.5K+
P: 2,851
An if block of code requires the next line to be indented. See Python Indentation documentation. Your code with required indentation:
Expand|Select|Wrap|Line Numbers
  1. for letter in 'Python':
  2.     if letter == 'h':
  3.         print letter
Oct 5 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.