I am trying to create a short program to do a task. Unfortunately I keep getting an error. The problem boils down to the following.
If I try to run:
line = "1+1"
int(line)
I would like it to return
2
However I get the following error:
invalid literal for int() with base 10: '1+1'
From looking online this is due to the fact that Python cannot recognize the fact that I have used a non-number. However without some rework I can't get around this.
I was hoping that there is a straight forward method for solving this. I have tried using float but that has the same problem.