In your code, the creation of an instance of the Deck class is created inside the Deck class.
To fix this, you should remove the indentation from the lines of code that create an instance of a class and use this class.
The code should look like this:
import random
class Card:
def __init__(self, value, suit):
self.value = value
self.suit = suit
def __str__(self):
return str(self.value) + " of " + self.suit
class Deck:
def __init__(self):
self.deck = []
self.suits = ["Hearts, Diamonds, Clubs, Spades"]
for i in range(4):
for j in range(14):
card = Card(j, self.suits[i])
self.deck.append(card)
def __str__(self):
for i in range(len(self.deck) - 1):
print(str(self.deck[i]) + "\n")
def drawCard(self):
if len(self.deck) == 0:
print("No cards left to draw")
else:
self.deck.pop()
def shuffle(self):
reorder = []
for i in range(len(self.deck) - 1):
rand = random.randint(0, len(self.deck) - 1)
reorder.append(self.deck[rand])
self.deck.remove(self.deck[rand])
self.deck = reorder
###
deckacards = Deck()
print(deckacards)
print(deckacards.shuffle())
print(deckacards)
print(deckacards.drawCard())