I cannot get the command cmp() to work.
Here is the code:
a = [1,2,3]
b = [1,2,3]
c = cmp(a,b)
print (c)
I am getting
If a or b is a class object, then the above answers will have the compilation error as below: For example: a is Class Clock: File "01_ClockClass_lab16.py", line 14, in cmp return (a > b) - (a < b) TypeError: '>' not supported between instances of 'Clock' and 'Clock'
Change the type with int() to remove the error:
def cmp(a, b): return (int(a) > int(b)) - (int(a) < int(b))