Currently creating a piece that takes values a given value in an array and adds 32
My IDE (PyCharm) recommended that I remove a redundancy in my code by doing the following
if ascii_key[i] >= 65 and ascii_key[i] <= 90:
ascii_key[i] = ascii_key[i] + 32
to
if 65 <= ascii_key[i] <= 90:
ascii_key[i] = ascii_key[i] + 32
Both solutions work for me, but I'm curious as to why this arrangement of conditions breaks
if ascii_key[i] <= 65 >= 90:
ascii_key[i] = ascii_key[i] + 32
I'd appreciate an explanation in pseudo-code if convenient, I'm still a bit novice
a < b < c
is just shorthand notation for(a < b) and (b < c)
. Writingascii_key[i] <= 65 >= 90
is the same as(ascii_key[i] <= 65) and (65 >= 90)
, which is probably not what you want. – jfaccioni Feb 13 '20 at 20:59