Python" IndentationError:期望一个缩进的块"检查缩进后

时间:2016-09-22 03:16:27

标签: python python-3.x

我一直收到以下错误,即使我已经检查了所有提示以确保它们的缩进而不是空格:

文件"",第13行     """

^ IndentationError:预期缩进块

import random

def guess_the_number():

    number, guesses = random.randint( 1, 20 ), 1

    inpName = input('Hello! Enter your name? \n')

    print('{}, there is a number f a number between 1 and 20.'.format(inpName))
    print('Take a guess what it is.')

    guess = input()

    while guess != number:

        if guess < number:
            print('That is too low.')
            print('Take another guess.')
            guesses += 1
            guess = input()

        else:
            print('That is to high.')
            print('Take another guess.')
            guesses += 1
            guess = input()

     if guess == number:
        print('Good job {} you guessed the number in {} guesses!'.format(inpName, guesses))

1 个答案:

答案 0 :(得分:0)

另外,对于您的进一步参考,Style Guide for Python Code推荐

  

空格是首选的缩进方法。选项卡应仅用于与已使用制表符缩进的代码保持一致。

相关问题