python显示以下错误“不明智”不匹配任何外部压痕级别。
我编写以下程序以显示列表中的随机颜色。我遇到了这个错误“不知道不符合任何外部压痕级别”
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 技术交流群。

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