IndentationError: expected an indented block

0 votes
while running:

    # HANDLE EVENT(S) #

for event in pygame.event.get():

if event.type == pygame.QUIT:

running = False

if event.type == pygame.MOUSEBUTTONDOWN:

if input_box1.collidepoint(event.pos):

active1 = True

input_text1 = ''

active2 = False

active3 = False

elif input_box2.collidepoint(event.pos):

active2 = True

input_text2 = ''

active1 = False

active3 = False

elif input_box3.collidepoint(event.pos):

active3 = True

input_text3 = ''

active1 = False

active2 = False

else:

if active1:

input_text2 = str(round(int(input_text1)*6.746,2))

elif active2:

input_text1 = str(round(int(input_text2)/6.746,2))

elif active3:

input_text1 = str(round(int(input_text3)*21.12,2))

active1 = False

active2 = False

active3 = False

if event.type == pygame.KEYDOWN:

if active1:

if event.type == pygame.KEYDOWN:

    if active1:

    if event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER:

active1 = False

input_text2 = str(round(int(input_text1)*6.746,2))

input_text3 = str(round(int(input_text1)*21.12,2))

elif event.key == pygame.K_BACKSPACE:

input_text1 = input_text1[:-1]

else:

input_text1 += event.unicode

elif active2:

if event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER:

active2 = False

input_text1 = str(round(int(input_text2)/6.746,2))

input_text3 = str(round(int(input_text1)*21.12,2))

elif event.key == pygame.K_BACKSPACE:

input_text2 = input_text2[:-1]

else:

input_text2 += event.unicode

elif active3:

if event.key == pygame.K_RETURN or event.key == pygame.K_KP_ENTER:

active3 = False

input_text1 = str(round(int(input_text3)/21.12,2))

input_text2 = str(round(int(input_text1)/6.746,2))

elif event.key == pygame.K_BACKSPACE:

input_text3 = input_text3[:-1]

else:

input_text3 += event.unicode

# UPDATE DATA #

color1 = ACTIVE_COLOR if active1 else INACTIVE_COLOR

color2 = ACTIVE_COLOR if active2 else INACTIVE_COLOR

color2 = ACTIVE_COLOR if active3 else INACTIVE_COLOR

txt_surface1 = font.render(input_text1, True, color1)

txt_surface2 = font.render(input_text2, True, color2)

txt_surface3 = font.render(input_text3, True, color2)

# RENDER GRAPHICS #

screen.fill(BG_COLOR)

screen.blit(header_surface, header_rect)

screen.blit(input1_label_surface, input1_label_rect)

screen.blit(input2_label_surface, input2_label_rect)

screen.blit(input3_label_surface, input3_label_rect)

screen.blit(txt_surface1, (input_box1.x+5, input_box1.y+5))

screen.blit(txt_surface2, (input_box2.x+5, input_box2.y+5))

pygame.draw.rect(screen, color1, input_box1, 2)

pygame.draw.rect(screen, color2, input_box2, 2)

pygame.draw.rect(screen, color2, input_box3, 2)

pygame.display.flip()

pygame.quit()
Oct 17 in Python by Baker
• 120 points

edited Oct 19 by Gitika 41 views

1 answer to this question.

0 votes

Hi, @Baker,

Putting in extra space or leaving one out where it is needed will surely generate an error message. Some common causes of this error include:

  •     Forgetting to indent the statements within a compound statement
  •     Forgetting to indent the statements of a user-defined function.

The error message IndentationError: expected an indented block would seem to indicate that you have an indentation error. It is probably caused by a mix of tabs and spaces. The indentation can be any consistent white space. It is recommended to use 4 spaces for indentation in Python, tabulation or a different number of spaces may work, but it is also known to cause trouble at times. Tabs are a bad idea because they may create different amounts of spacing in different editors. 

For more information go through this: https://www.edureka.co/community/49336/python-error-indentationerror-expected-an-indented-block

answered Oct 19 by Gitika
• 48,320 points

Related Questions In Python

0 votes
3 answers

Python error "IndentationError: expected an indented block"

IndentationError:  what is the mean READ MORE

answered Oct 14 in Python by anonymous
• 140 points
75,749 views
0 votes
1 answer

I was written the python program, am getting error message "IndentationError: expected an indented block"

Hi@Thiyagarajan, You have one else block in your ...READ MORE

answered May 27 in Python by MD
• 77,660 points
1,438 views
0 votes
1 answer

IndentationError: expected an indented block

Hello @ nishit, Indentation means the space from margin to ...READ MORE

answered Aug 9 in Python by Niroj
• 76,540 points
929 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,557 views
0 votes
0 answers
+4 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,800 points
1,172 views
0 votes
1 answer

I've been trying to run this code, but the error says "Expected an indented block" for the line, " word_as_list[index] = guess."

Hi, @Paradox, The error message IndentationError: expected an indented ...READ MORE

answered 3 days ago in Python by anonymous
• 48,320 points
79 views
+1 vote
7 answers

Count the frequency of an item in a python list

To count the number of appearances: from collections ...READ MORE

answered Oct 18, 2018 in Python by tinitales
13,623 views