So for context: I'm trying to create a simple chess program in python with pygame (2.0.0). Since I don't want to create every single of the 64 tiles manually I am looking for a way to create them using a function. Since in chess tiles are named from a1 to h8 (files and ranks) I want the objects to have this kind of names (a1, a2,...). The tile-class is until now very simple:
class tile:
def __init__(self):
self.piece = None
Then I made two lists: one for the files and one for the ranks. Then two for-loops (one in another) so that for every single combination it would create a tile-object:
files = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
ranks = ['1', '2', '3', '4', '5', '6', '7', '8']
for f in files:
for r in ranks:
f + r = tile()
Now my problem: python doesn't allow this ;( I want to create 64 tile-objects with names from a1 to h8. Is there any way for this?