What's the pythonic way to do the math operation on number in text (string) format? The result must also be a string. Now I am using the following:
a = str(0.12345678)
b = str(float(a)**-1)
print(b)
CodePudding user response:
print(str(0.12345678**-1))
Although i don't get it why are you creating 2 variables and why are you converting from float to string and then back to srting ??
CodePudding user response:
I think this the answer of you problem :
a = 0.12345678
ope = a * -1
ans = str(ope)
print(ans)