What has been done already:
Each letter of a string comprised of fixed number of letters converted to a number: e.g. "TAAPAS" is now "122324"
I was forced to perform this using the clunky code:
s = s1.replace("A", "2").replace("P", "3").replace("T", "1").replace("S", "4")
because when I tried a more standard approach suggestion on an earlier forum, the code failed to modify every letter:
numerize = {'A':'2', 'P':'3', 'T':'1', 'S':'4'}
for k, v in numerize.iteritems():
string2 = string1.replace(k, v)
Q1: Any suggestions on why this code isn't working in my situation? I even tried the following, with the same result:
numerize = {'A':'2', 'P':'3', 'T':'1', 'S':'4'}
for k, v in numerize.iteritems():
for i in string1:
string2 = string1.replace(k, v)
Anyhow, on to what I want to do next:
On my sequence of numbers "122324", I want to perform a defined series of numerical operations, and when the last operation is reached, I want it to start over at the beginning...repeating this as many times as necessary to reach the end of my integer.
e.g. +, *, /
such that it looks something like:
y = 1 + 2 * 2 / 3 + 2 * 4 ...
Q2: Must this be performed on a list of numbers? or is it possible to iterate through the positions of an integer as one can the positions of a string. If not, it's not a big deal to just split my string prior to converting it.
Q3. What is the code to accomplish such a task? And is there a name for this type of procedure? Using the keywords "recycle" and "math functions" leaves me dry...and it seems that the itertools library doesn't do math (or so there are no examples on the webpage).
Thank you!