How we can perform mathematical operation on string in python.
Consider below example
with open('/home/akashk/projects/math.txt') as f:
content = f.readlines()
content = [x.strip() for x in content]
for x in content:
print(x)
print(type(x))
output is like
1abc0+5*1hv0
I want to perform operation using operand and operators
above should be considered as 10+5*10 = 60 In short remove characters and perform mathematical operation on operands.
eval('10+5*10') which gives 60 but it will not handle characters.