簡體   English   中英

檢查縮進后的Python“IndentationError:應為縮進塊”

[英]Python "IndentationError: expected an indented block" After Checking Indentation

即使我已經檢查了所有標識以確保它們是縮進而不是空格,我仍然收到以下錯誤:

文件“”,第 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))

此外,為了您的進一步參考, Python 代碼風格指南推薦

空格是首選的縮進方法。 制表符應僅用於與已使用制表符縮進的代碼保持一致。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM