Python Forum
IndentationError: expected an indented block
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IndentationError: expected an indented block
#1
class Player:
    def __init__(self):
        self.inventory = [items.RedBloodCell()]
        self.hp = 100
        self.location_x, self.location_y = world.starting_position
        self.vicory = false

    def is_alive(self):
        return self.hp > 0

    def print_inventory(self):
        for item in self.inventory:

    def move(self, dx, dy):
        self.location_x += dx
        self.location_y += dy
        print(world.tile_exists(self.location_x, self.location_y).intro_text())
IndentationError: expected an indented block on Line 14
Reply
#2
you have for loop on line 12, but there is no loop body.

def print_inventory(self):
    for item in self.inventory:
        print(item) # this is just an example, you need to do something in the loop body
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
If you are not yet ready to write the code for printing the inventory you can always put pass on line 13.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to write in text file - indented block Joni_Engr 4 6,359 Jul-18-2022, 09:09 AM
Last Post: Hathemand
  how far is this line indented? Skaperen 3 1,286 May-30-2022, 05:49 PM
Last Post: Skaperen
  IndentationError: unexpected indent dee 3 2,227 May-02-2022, 02:15 AM
Last Post: dee
  error "IndentationError: expected an indented block" axa 4 2,858 Sep-08-2020, 02:09 PM
Last Post: ibreeden
  IndentationError: unexpected indent jk91 1 2,338 Feb-27-2020, 08:56 PM
Last Post: buran
  IndentationError jagannath 1 2,435 Nov-04-2019, 07:41 AM
Last Post: buran
  IndentationError on installed package evvvonder 3 2,968 Jun-29-2019, 10:30 PM
Last Post: Gribouillis
  how do i fix this problem - IndentationError? GrandMaster101 8 7,588 Apr-04-2019, 09:38 PM
Last Post: carloszoom3000
  [SOLVED] Expected An Indented Block Panda 4 5,927 Jun-06-2018, 09:57 PM
Last Post: Larz60+
  Indentationerror Jack_Sparrow 4 4,153 May-16-2018, 05:50 PM
Last Post: Jack_Sparrow

Forum Jump:

User Panel Messages

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