counter = {} mapdata = "1293812903111892371029118907239283902" for tile in mapdata: if tile not in counter: counter[tile] = 1 else: counter[tile] += 1 print(counter)