Lists cmp() Function

In Python Built-In Lists cmp() function is used to compare 2 elements in the given list.

Syntax:
There are 2 parameters used in Lists cmp() Function : list1 The first list to be compared and list2 The second list to be compared.
Example:
#!/usr/bin/python

list1, list2 = [123, 'xyz'], [456, 'abc']
print cmp(list1, list2)
print cmp(list2, list1)
list3 = list2 + [786];
print cmp(list2, list3)

Comments are closed.