ziok wrote: > hi .. > > i'm learning python .i have a book with examples. i did the examples for > "if" and have the same errors... > here is the simple code(two of them) >>>> z=['ze','se'] >>>> for s in z: > ... if s=='ze': > File "<stdin>", line 2 > if s=='ze': > ^ > IndentationError: expected an indented block
Python uses indentation to define blocks. For example, to show which statements are controlled by a for or if statement, the controlled statements are indented. Your book should talk about this. So when typing these examples you need to indent the lines after the for, if or while. The indentation can be any consistent white space. Four spaces is a very common indent. When typing at the interactive prompt I usually use two spaces just because it's easier to type. Your code should look something like this: >>> z=['ze','se'] >>> for s in z: ... if s=='ze': ... print 'found ze' ... else: ... print 'not ze' Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor