python显示以下错误“不明智”不匹配任何外部压痕级别。

发布于 01-21 16:34 字数 559 浏览 0 评论 0原文

我编写以下程序以显示列表中的随机颜色。我遇到了这个错误“不知道不符合任何外部压痕级别”

import random

colors = [ "white", "black", "red", "green", "Yellow", "purple", "grey "]
while True :
    color = colors [random.randint(0, len(colors)-1)]
    guess = input ("i'm thinking about a color , can you guress it :")
    while True:
         if (color == guess.lower()):
             break
        else:
             guess = input ("Nope. Try again :")

        print ( "you guessed it ! I was thinking about ", colour)

        play_again = input ("Let's play again T")   

I write a following program to display the random color from list . i getting this error "unindent does not match any outer indentation level "

import random

colors = [ "white", "black", "red", "green", "Yellow", "purple", "grey "]
while True :
    color = colors [random.randint(0, len(colors)-1)]
    guess = input ("i'm thinking about a color , can you guress it :")
    while True:
         if (color == guess.lower()):
             break
        else:
             guess = input ("Nope. Try again :")

        print ( "you guessed it ! I was thinking about ", colour)

        play_again = input ("Let's play again T")   

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夢归不見2025-01-28 16:34:20

This error is mostly observed when there is a mixup of Tab and Space characters while indenting Python code.
您可以使用选项卡或空格来缩进代码块。不要同时使用两者。
您的代码需要这样

while True:
    if (color == guess.lower()):
        break
    else:
        guess = input ("Nope. Try again :")

    #some more

This error is mostly observed when there is a mixup of Tab and Space characters while indenting Python code.
You can use either tab or spaces to indent a code block. Don't use both at a same time.
Your code needs to be like this

while True:
    if (color == guess.lower()):
        break
    else:
        guess = input ("Nope. Try again :")

    #some more
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文