Im working on the code the finding the maximum evaluation (ignoring precedence) such as
2
5+ 3*2
-1 + -4 * -3
Output
16
40000000000
I have the following code which returns the following error:
ValueError: invalid literal for int() with base 10: '-' m[i][i] = int(d[i]) File
Note: I have looked through the other questions with a similar error, but this is different from each of them. Im using Python 3and it docent work.
def get_maximum_value(expression):
expression="".join(expression.split())
op = expression[1:len(expression):2]
d = expression[0:len(expression)+1:2]
n = len(d)
m = [[0 for i in range(n)] for j in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
m[i][i] = int(d[i])
M[i][i] = int(d[i])
for s in range(1,n):
for i in range(n-s):
j = i + s
m[i][j], M[i][j] = MaxValue(i,j,op,m,M)
return M[0][n-1]
num=int(input())
for i in range(num):
expression=input()
print (get_maximum_value(expression))
However, it shows ValueError: invalid literal for int() with base 10: '-' m[i][i] = int(d[i])
.
I tried to change the int to float but it still doesnt work.