I'm trying to create a machine that allows a user to input two numbers and determine whether they are approximately equal to each other.
This has been working for whole numbers but as soon as I test it with decimals I get ValueError: could not convert string to float: '.'
InputString=input("Enter 2 numbers in the form Number1,Number2: ")
SortedInputString=sorted(InputString)
print(SortedInputString[1])
print(SortedInputString[2])
N1=float(SortedInputString[1])
N2=float(SortedInputString[2])
def approx_equal(N1,N2):
if N1-N2>=1e-6 :
return True
else:
return False
print("Is", N1, "equal to",N2,"?",approx_equal(N1,N2))