Python Forum
IndentationError: expected an indented block
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IndentationError: expected an indented block
#1
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
Reply
#2
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
Reply
#3
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'
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help with "IndentationError: expected an indented block" hequ 3 6,542 Mar-02-2020, 06:26 AM
Last Post: Pranav
  IndentationError: unexpected indent belikewater 6 10,944 Oct-31-2017, 12:32 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020