1

I mean when giving a string '1+2*3*4+5-1+6/2' will give me the result 32 without using eval every time I searched it gave me answers with eval.

Every time I try and put in the multiply it wont work even if I put it on a different for to work first and the Len was with small letter but it didn't let me upload the question so I wrote it with upper letter:

def compute(string):
    total = 0

    for index in range(Len(string)):
     if string[index] == '+':
            total += int(string[index+1])
            print total
        if string[index] == '-':
            total -=int(string[index+1])
            print total
Albert Lazaro de Lara
  • 2,540
  • 6
  • 26
  • 41
  • 2
    Possible duplicate of [Evaluating a mathematical expression in a string](https://stackoverflow.com/questions/2371436/evaluating-a-mathematical-expression-in-a-string) – Georgy May 02 '18 at 09:00
  • What do you mean without eval? – Eypros May 02 '18 at 09:07
  • without using the builtin eval but never mind got it already –  May 02 '18 at 16:47

0 Answers0