I tried to create 52 different object to present cards.
group = ["Karo", "Sinek", "Kupa", "Maca"]
rank = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
cardlist = {}
class Card:
pass
def __init__(self, cins, seviye):
self.cins = cins
self.seviye = seviye
x = 1
for i in group:
kart = "kart" + str(x) # kart will have values like kart1, kart2...
for j in rank:
kart = Card(i,j) # ^1
cardlist[x] = kart
x += 1
print kart41 # ^2
I wanted to create objects with kart's name. I mean in the first loop kart1 would be the object name and in the second loop kart2... And if I print kart here, I can see all objects with different object id's.
But if I try to print kart41 here, it says that kart41 is not defined.
Can somebody please explain me why kart41 is not defined at 1. And how can I reach the name of object which is defined at 1?