As per title, I am trying to check if an input string is either 'white' or 'black', if not to raise an exception.
I came up with the following:
class Player:
def __init__(self):
self.name = input('Enter you Name: ')
colour = input('Now choose your army colour between "white" and "black": ')
if colour is not 'white' or colour is not 'black':
raise Exception('colour must be either "white" or "black"')
else:
self.colour = colour
def get_name(self):
return self.name
def get_colour(self):
return self.colour
player = Player()
Which looks ok to me, but when I type 'white' or 'black' it rises the exception anyway.
C:\Users\oricc\PycharmProjects\practisingDrowing\venv\Scripts\python.exe C:/Users/oricc/PycharmProjects/practisingDrowing/canvas.py
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Enter you Name: John
Now choose your army colour between "white" and "black": white
Traceback (most recent call last):
File "C:/Users/oricc/PycharmProjects/practisingDrowing/canvas.py", line 67, in <module>
player = Player()
File "C:/Users/oricc/PycharmProjects/practisingDrowing/canvas.py", line 56, in __init__
raise Exception('colour must be either "white" or "black"')
Exception: colour must be either "white" or "black"
Process finished with exit code 1
Where is the error?