I'm making a Card class and need to make sure that the suit is valid. When I call on the Card class and construct one setting the suit to 'Jordan' it actually ok's that suit and prints 'Ace of Jordan'. Instead it should become the default, of Spades. What am I doing wrong in my code that will not set it to the default suit? TIA guys
class Card:
def __init__(self, value, suit):
validSuit(suit)
self.suit = suit
self.face = value
if self.face >= 1 and self.face <= 13:
if self.face == 1:
self.face = 'Ace'
elif self.face == 11:
self.face = 'Jack'
elif self.face == 12:
self.face = 'Queen'
elif self.face == 13:
self.face = 'King'
else:
self.face = 'Ace'
def getSuit(self):
return self.suit
def getFaceValue(self):
return self.face
def __str__(self):
return str(self.face) + ' of ' + str(self.suit)
def validSuit(suit):
if suit != 'Clubs' or suit != 'Spades' or suit != 'Hearts' or suit != 'Diamonds':
suit = 'Spades'
return suit
else:
return suit
And here is the driver:
from card import *
def main():
card = Card(14, 'Jordan')
print(card)
# prints 'Ace of Jordan'
main()