Deck card class in python
Question: I am working on creating a class for the first time, and I am thinking that I
have done every thing to get it run, but I still get bunch of issues which is
`'list' object has no attribute 'shffule'` so the problem here is it will not
shuffle the cards, and it will not tell the remaining cards, can any one tell
me what am I doing wrong? Thanks in advance

    
    
     import random
    
     class card_deck:
         def __init__(self, rank, suite, card):
    
    
            self.rank= rank
             self.suite = suite
        def ranks(self):
             return self.rank
        def suites(self):
             return self.suite
         def cards(self,card):
             suit_name= ['The suit of Spades','The suit of Hearts', 'The suit of Diamonds','Clubs']
             rank_name=['Ace','2','3','4','5','6','7','8','9','10','Jack','Queen','King']
    
    
         def value(self):
             if self.rank == 'Ace':
                 return 1
             elif self.rank == 'Jack':
                 return 11
             elif self.rank == 'Queen':
                 return 12
             elif self.rank == 'King':
                 return 13
         def shffule(self):
             random.shuffle(self.cards)
         def remove(self,card):
             self.cards.remove(card)
    
    
         def cardremaining(self):
            self.suite-self.rank
    
    
    
    
     def main():
         try:
             deck=[]
             for i in ['Spades','Hearts', ' Diamonds','Clubs']:
             for c in ['Ace','2','3','4','5','6','7','8','9','10','Jack','Queen','King']:
                     deck.append((c, i))
             deck.shffule
    
             hand = []
             user =eval(input('Enter a number of cards: 1-7 '))
             print()
             while user <1 or user >7:
                 print ("Only a number between 1-7:")
                 return main()
    
             for i in range(user):
                 hand.append(deck[i]) 
             print (hand)
         except ValueError:
             print("Only numbers")
             main()
    


Answer: Apart from your code containing many small errors; I will try to answer your
main problems.

If you are going to use `shffule` _[sic]_ method of `card_deck` class, then
you first need to create an instance of that class(whereas you tried to call
that method with a list). Like this:

    
    
    deck = card_deck(some_rank,some_suit,some_card)
    deck.shffule() #Now you can call the method
    

Now, since you made it a class instance, you cannot get items from it like
`hand.append(deck[i])`  
Unless you defined the method `__getitem__` in your class definition, like
this:

    
    
    #this will be in your class definition
    def __getitem__(self,i):
        return self.card_list[i] #Of course you have to define a list of cards in your class too.
    

In my opinion, you should spend a little more time trying to understand how is
a class defined, how does methods work and how to access members of a class.
After that you will be doing much better here

