Python Forum

Full Version: IndentationError: expected an indented block
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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
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'
you cannot run py file like this
See https://python-forum.io/Thread-Basic-How...ython-code for more info on how to execute python code.