y, December 12, 2023 3:58 AM
To: python-list@python.org
Subject: Re: A problem with str VS int.
Op 12/12/2023 om 9:22 schreef Steve GS via Python-list:
> With all these suggestions on
> how to fix it, no one seems to
> answer why it fails only when
> entering a two-digit number.
> O
On 12/12/23 21:22, Steve GS wrote:
With all these suggestions on
how to fix it, no one seems to
answer why it fails only when
entering a two-digit number.
One and three work fine when
comparing with str values. It
is interesting that the
leading 0 on a two digit
worked. Still, one digit and
thre
Op 12/12/2023 om 9:22 schreef Steve GS via Python-list:
With all these suggestions on
how to fix it, no one seems to
answer why it fails only when
entering a two-digit number.
One and three work fine when
comparing with str values. It
is interesting that the
leading 0 on a two digit
worked. Stil
now more of a
curiosity as I did use the
integer comparisons.
SGA
-Original Message-
From: Python-list
On
Behalf Of dn via Python-list
Sent: Sunday, December 10,
2023 12:53 AM
To: python-list@python.org
Subject: Re: A problem with
str VS int.
On 10/12/23 15:42, Steve GS
via Python-list
On 10/12/23 15:42, Steve GS via Python-list wrote:
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: ")
On 12/9/2023 9:42 PM, Steve GS via Python-list wrote:
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: ")
Steve,
I would say converting to a number, as you eventually did, is the way to go.
When you compare character strings, it will not be in numeric order. Compare
"80" with "400" and since 8 is greater than 4, the comparison is over and
"80" is greater then "40" even though 80 is way less than 400.