IndentationError:应在函数上缩进块

时间:2018-12-31 12:02:44

标签: python

我正在用python为我的朋友做一个测验,但遇到一个错误说: IndentationError:应缩进的块 这是我的代码:

#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

这是错误的样子:

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

如果这可以帮助您更好地理解,请使用Sublime Text 3最新版本。 我试图“将缩进转换为制表符”,但这并不能解决问题。

-真诚的,Alex Bulatovic

1 个答案:

答案 0 :(得分:2)

修复代码缩进。

更改

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

进入

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