0

I was making a quiz for my friend in python and I ran into an error saying: IndentationError: expected an indented block Here is my code:

#Tests for the people who eat cold burekses
#By Cross!Alex21
from Question import Question
import random
import time
import os

sins = 0
false_answ = 0
true_answ = 0
text_to_num_situ = False
srb = False
en-uk = True
how_many_left = 0
sum_all = 0

first = False
check_internet_connection_numGen = random.randint(0,1)
if check_internet_connection_numGen == 0:
    first = False
else:
    first = True
if first == True:
    def check_internet_connection():
        shoud_print = False
        not_shoud_print = False
        sys.stdout.write('Checking internet connection . . .')
        sys.stdout.flush()
        try:
            r = sys.stdout.write('The internet is stabled')
            print ('OK')
            should_print = False
            not_should_print = True
        except:
            print ('Double G destroyed the internet, sorry.')
            should_print = True
            not_should_print = False
        if should_print == False and not_should_print == True:
            r = req.get('file:///D:/Stuff/Coding/python%20coding/command.txt')
        if should_print == True and not_should_print == False:
            command_list = ["check_answersFalse","check_answersTrue","check_Sins","check_questions","check_questionsLeft"]
            for element in command_list:
                print(element)
    check_internet_connection()
    del first
class Question:
    def __init__(self, prompt, answer):
    self.prompt = prompt
    self.answer = answer
class Questions():
    question_prompts = [
    "Who is the first animated band in the world?\n(A)Gorilaz\n(B)Alvin and the Chipmunks\n(X)J̶e̶s̶s̶ Naruto\n(D)Hentai"
    "Is it safe to eat a raw potato?\n(A)Yes\n(B)No"
    "Solve this math problem: burek(vruc + hladan) + burek = ?\n(A)1/4 of burek (middle hot)(B)Burekses (Cold)\n(C)1/Atom of Burek (Hot) and 1/8"
    "When you eat a gum with a water, will the gum get hard?\n(A)Yes\n(B)No\n"
    "Memes?\n(A)memes\n(B)memes\n(C)memes\n(D)fucking hippies"
    "Is coding hard?\n(A)Yes\n(B)No"
    ]
    question = [
        Question(question_prompts[0], "B"),
        Question(question_prompts[1], "B"),
        Question(question_prompts[2], "A"),
        Question(question_prompts[3], "A"),
        Question(question_prompts[4], "D"),
        Question(question_prompts[5], "B"),
    ]
    question_pick = random.randint(0,5) and question = question_pick
    if answer == question.answer:
        sins += 10
        true+=1
    print("Right, adding " + sins " for that")
    if answer != question.answer:
        false +=1

This is how the error looks like:

    self.prompt = prompt
       ^
IndentationError: expected an indented block

If this helps you to understand better, I use Sublime Text 3 latest version. I tried to "Convert Indentation to Tabs" but that didn't solve the problem.

--Sincerely, Alex Bulatovic

  • This [answer](https://stackoverflow.com/a/23540812/7932273) might help you. – Sociopath Dec 31 '18 at 12:05
  • The error message will always tell you your problem. Look at which line it says the error is on and read the message. In your case, go to the line stating `self.prompt` and since it expected an indebted block, go ahead and indent it. – N Chauhan Dec 31 '18 at 12:35

1 Answers1

2

Fix code indentation.

Change

class Question:
    def __init__(self, prompt, answer):
    self.prompt = prompt
    self.answer = answer

Into

class Question:
    def __init__(self, prompt, answer):
        self.prompt = prompt
        self.answer = answer
Employee
  • 3,109
  • 5
  • 31
  • 50