Python Forum
IndentationError: expected an indented block - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: IndentationError: expected an indented block (/thread-6702.html)



IndentationError: expected an indented block - python1980 - Dec-03-2017

I have a list e2f, (english to french), i am trying to create a new directory f2e, i am getting
IndentationError: expected an indented block, i used space, tab but not working

how do i resolve it ? also, is : necessary after the for loop syntax

e2f ={'dog':'chien','cat':'chat','walrus':'morse'}
>>> for e,f in e2f(items):
... f2e(f)=e
  File "<stdin>", line 2
    f2e(f)=e
      ^
IndentationError: expected an indented block



RE: IndentationError: expected an indented block - buran - Dec-03-2017

at the moment it is at the same indent level as the if line above. Indnet line #2 one level. By the way - better write your program in a file instead of using interactive interpreter


RE: IndentationError: expected an indented block - python1980 - Dec-03-2017

my .py file has exactly this, pls let me know why i am unable to attach the .py file.

for e, f in e2f(items):
    f2e(f)=e
when i create the empty directory in python interpretor and call the file, i get the error

>>> e2f ={'dog':'chien','cat':'chat','walrus':'morse'}
>>> f2e={}
>>> f2e.py
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'dict' object has no attribute 'py'



RE: IndentationError: expected an indented block - buran - Dec-03-2017

you cannot run py file like this
See https://python-forum.io/Thread-Basic-How-to-Execute-python-code for more info on how to execute python code.