python error - set

ittechlab
ittechlab used Ask the Experts™
on
>>> s1 = set([1,2,3,4,5,6])
>>> for ele in s1:
... print(ele)
  File "<stdin>", line 2
    print(ele)
        ^
IndentationError: expected an indented block
>>>
>>> s1 = set([1,2,3,4,5,6])
>>> for ele in s1:
... print ele
  File "<stdin>", line 2
    print ele
        ^
IndentationError: Missing parentheses in call to 'print'
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Topic Advisor
Most Valuable Expert 2016
Commented:
Python needs indentation of source code, try this:
s1 = set([1,2,3,4,5,6])
for ele in s1:
    print(ele)

Open in new window

Notice the spaces before the print statement - this is required.
Suhas .Senior QA Manager
Commented:
Hi,
Please refer https://www.python.org/dev/peps/pep-0008/ for python style guide.
This will not just help for list, but for all kind of formatting in python.

And also google guide for python https://google.github.io/styleguide/pyguide.html

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial