Im farely new to python but I want to convert a string of both numbers and letters into an array. Is there somehow that I can make the numbers without a string and keep the letters as a string?
Example: string = "2A3M4D8"
I want the A's to be an addition numbers on both side. The M to be multiply, D, divide and S, subtract. So the program should be calculating ((2+3)*4)/8=2,5
import numpy as np
def compile(program):
program=map(int,program())
newvector=np.array([])
for i in range(len(program)):
if program[i]=="A":
R=program[i-1]+program[i+1]
elif program[i]=="S":
R=program[i-1]-program[i+1]
elif program[i]=="M":
R=program[i-1]*program[i+1]
elif program[i]=="D":
R=program[i-1]/program[i+1]
newvector=np.concatenate(newvector,R)
result=sum(newvector)
return result
print(compile("3A3"))