'python showing following error "unindent does not match any outer indentation level "
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")
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Python learner |
