<filename>Python/Card Game(Blackjack)/Card.py
class Card:
    def __init__(self,rank,suit): # instance recevies two parameters rank and suit
        self.rank = rank
        self.suit = suit
        self.rank_list = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'] # a list contains all ranks
        self.suit_list = ['H', 'C', 'D', 'S'] # a list containing all suits
        assert self.rank.upper() in self.rank_list, 'Invalid Rank' # checks if the rank is in the list, not case sensitive
        assert self.suit.upper() in self.suit_list, 'Invalid Suit' # checks if the suit is in the list, not case sensitive
        
    def get(self): # returns rank and the suit
        return self.rank+self.suit
    
    def get_rank(self): # returns rank
        return self.rank
    
    def get_suit(self): # returns suit
        return self.suit
    
    def __gt__(self,other): # checks if the rank of the passed card is smaller
        for i in range(len(self.rank_list)): # ranks are ordered in increasing order in self.rank_list, so higher the rank, higher the index
            if self.rank_list[i] == self.rank: # checks for the rank in the list and stores the index
                rank = i
            if self.rank_list[i] == other.rank:
                rank_other = i
        return rank > rank_other # compares the index to determines if the passed card's rank is smaller or greater
    
    def __lt__(self,other): # checks if the rank of the passed card is greater
        for i in range(len(self.rank_list)): # ranks are ordered in increasing order in self.rank_list, so higher the rank, higher the index
            if self.rank_list[i] == self.rank: # checks for the rank in the list and stores the index
                rank = i
            if self.rank_list[i] == other.rank:
                rank_other = i
        return rank < rank_other # compares the index to determines if the passed card's rank is smaller or greater
    
    def __eq__(self,other):
        return self.rank == other.rank # returns if the rank of the passed card is equal
    
    def __str__(self): # converts card object to a printable form
        return self.rank + self.suit
    
    def convert_rank(self,rank): # converts rank accordding to its positon in the list, adds two to the index as the index counting starts from 0 in python and the ranks start from 2
        for i in range(len(self.rank_list)):
            if self.rank_list[i] == rank:
                return i+2
        

<filename>Python/Card Game(Blackjack)/Card.py
class Card:
    def __init__(self,rank,suit): # instance recevies two parameters rank and suit
        self.rank = rank
        self.suit = suit
        self.rank_list = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'] # a list contains all ranks
        self.suit_list = ['H', 'C', 'D', 'S'] # a list containing all suits
        assert self.rank.upper() in self.rank_list, 'Invalid Rank' # checks if the rank is in the list, not case sensitive
        assert self.suit.upper() in self.suit_list, 'Invalid Suit' # checks if the suit is in the list, not case sensitive
        
    def get(self): # returns rank and the suit
        return self.rank+self.suit
    
    def get_rank(self): # returns rank
        return self.rank
    
    def get_suit(self): # returns suit
        return self.suit
    
    def __gt__(self,other): # checks if the rank of the passed card is smaller
        for i in range(len(self.rank_list)): # ranks are ordered in increasing order in self.rank_list, so higher the rank, higher the index
            if self.rank_list[i] == self.rank: # checks for the rank in the list and stores the index
                rank = i
            if self.rank_list[i] == other.rank:
                rank_other = i
        return rank > rank_other # compares the index to determines if the passed card's rank is smaller or greater
    
    def __lt__(self,other): # checks if the rank of the passed card is greater
        for i in range(len(self.rank_list)): # ranks are ordered in increasing order in self.rank_list, so higher the rank, higher the index
            if self.rank_list[i] == self.rank: # checks for the rank in the list and stores the index
                rank = i
            if self.rank_list[i] == other.rank:
                rank_other = i
        return rank < rank_other # compares the index to determines if the passed card's rank is smaller or greater
    
    def __eq__(self,other):
        return self.rank == other.rank # returns if the rank of the passed card is equal
    
    def __str__(self): # converts card object to a printable form
        return self.rank + self.suit
    
    def convert_rank(self,rank): # converts rank accordding to its positon in the list, adds two to the index as the index counting starts from 0 in python and the ranks start from 2
        for i in range(len(self.rank_list)):
            if self.rank_list[i] == rank:
                return i+2
        

# instance recevies two parameters rank and suit # a list contains all ranks # a list containing all suits # checks if the rank is in the list, not case sensitive # checks if the suit is in the list, not case sensitive # returns rank and the suit # returns rank # returns suit # checks if the rank of the passed card is smaller # ranks are ordered in increasing order in self.rank_list, so higher the rank, higher the index # checks for the rank in the list and stores the index # compares the index to determines if the passed card's rank is smaller or greater # checks if the rank of the passed card is greater # ranks are ordered in increasing order in self.rank_list, so higher the rank, higher the index # checks for the rank in the list and stores the index # compares the index to determines if the passed card's rank is smaller or greater # returns if the rank of the passed card is equal # converts card object to a printable form # converts rank accordding to its positon in the list, adds two to the index as the index counting starts from 0 in python and the ranks start from 2