I just started messing with programming and started with Python. Part
of my first project deals with translating numerical values to letters.
I would like to be able to do the reverse as well, letters to numbers,
sort of a table for lookup and a table for reverse lookup. I thought
that a dictiona
Thanks so much. That seems to have it. This is the sort of thing I
had before:
#!/usr/local/bin/python
# make a short dictionary
d1 = {'A' : '1', 'B' : '2', 'C' : '3'}
for letter in d1.keys(): print letter, '\t', d1[letter]
# make a space between the output of the 2 dictionaries
print '\n'
What is the difference between
" d1 = {'A' : '1', 'B' : '2', 'C' : '3'} "
and
" d1 = dict(A = 1, B = 2, C = 3) " ?
All of the dictionary examples I saw (python.org, aspn.activestate.com,
Learning Python by Lutz, among others) use d={'x' : 'y'}.
--
http://mail.python.org/mailman/listinfo/pyt
Thanks. That is exactly what I meant.
In d2, A is not 'A' because it is being set to 1, whereas in d1, using
A instead of 'A' means A is an undeclared variable instead of a string?
--
http://mail.python.org/mailman/listinfo/python-list
The end of what I was trying to do was encode and decode using ITA2
International Telegraph Alphabet 2, more commonly called Baudot. It
uses 5 bit binary but with the use of a shift up or a shift down can
utilize 2 tables of 32- one for letters one for figures.
A better explanation of ITA2 here: