A problem with str VS int.
Steve GS
Gronicus at SGA.Ninja
Sat Dec 9 21:42:06 EST 2023
If I enter a one-digit input or a three-digit number, the code works but if I enter a two digit number, the if statement fails and the else condition prevails.
tsReading = input(" Enter the " + Brand + " test strip reading: ")
if tsReading == "": tsReading = "0"
print(tsReading)
if ((tsReading < "400") and (tsReading >= "0")):
tsDose = GetDose(sReading)
print(tsReading + "-" + tsDose)
ValueFailed = False
else:
print("Enter valid sensor test strip Reading.")
I converted the variable to int along with the if statement comparison and it works as expected.
See if it fails for you...
Steve
More information about the Python-list
mailing list