I have to create a dictionary using only capital letters and I need to store the bit value too. The capital letters however are in groupings of 3 and 2 letters (i.e., AA or ZZZ). Now, my code works fine but I would like to neaten it up (because I'm sure I've took a few naughty routes) and I'd appreciate any help!
a = 65
b = 65
c = 65
ab = {}
#This range size gives the perfect AA-ZZZ range of numbers I need.
for i in range(17576):
byt1 = a << 16
byt2 = b << 8
byt3 = c
#This is creating my 3-byte key/value pair
threeByte = (byt1 + byt2 + byt3)
ab["%s%s%s" % (chr(a),chr(b),chr(c))] = threeByte
#This is the 2-byte variant
twoByte = (byt2 + byt3)
ab["%s%s" % (chr(b),chr(c))] = twoByte
#This section iterates from 65 (Capital 'A') to 90 (Capital 'Z') for all
#3 bytes, and the print is just so I could see it working
if c < 90:
c = c+1
elif b < 90:
b = b+1
c = 65
else:
a = a+1
c = 65
b = 65
#print "%s %s %s %s" %(i,a,b,c)