Firts, your original code - no need to wrap
As suggested by jefsummers - you can use Decimal, instead of float
input()
function in str()
. input()
returns str
in any case.As suggested by jefsummers - you can use Decimal, instead of float
from decimal import Decimal var1=Decimal(input("What is Var1?")) #For example user inputs 8.10 var2=Decimal(input("What is Var2?")) #For example user inputs 6.80 var3 = var1 - var2 print(var3)Another option is to use string formatting when printing the result of deduction
var1=float(input("What is Var1?")) #For example user inputs 8.10 var2=float(input("What is Var2?")) #For example user inputs 6.80 var3 = var1 - var2 print(f'{var3:.2f}')
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs