I am writing a code where the program draws the amount of cards that was determined by the user. This is my code:
from random import randrange
class Card:
def __init__(self, rank, suit):
self.rank = rank
self.suit = suit
self.ranks = [None, "ace", "2", "3", "4", "5", "6", "7", "8",
"9", "10", "jack", "queen", "king"]
self.suits = {"s": "spades","d": "diamonds","c": "clubs","h": "hearts"}
def getRank(self):
return self.rank
def getSuit(self):
return self.suit
def __str__(self):
return "%s of %s" % (self.ranks[self.rank], self.suits.get(self.suit))
def draw():
n = input("Enter the number of cards to draw: ")
for i in range(n):
a = randrange(1,13)
b = randrange(1,4)
c=Card(a,b)
print (c)
draw()
And this is the error I keep getting:
Traceback (most recent call last):
File "main.py", line 31, in <module>
draw()
File "main.py", line 24, in draw
for i in range(n):
TypeError: 'str' object cannot be interpreted as an integer
Any help would be appreciated.
