You should not use key=int
in c.sort(key=int)
as c
is already a list of int
s due to you creating it via c.append(int(digit))
.
However the key issue is that c.sort()
is in-place and as such returns None
, instead use sorted
which returns a sorted list
:
csort = sorted(c)
And then you can print the boolean result of the comparsion via:
print c == csort
solved The digits of a number in ascending order. (comparing) [closed]