The syntax of Python has been designed to allow operators that work with multiple types. For instance, 1+1 evaluates into 2, and "a"+"b" evaluates into "ab". Similarly, one can write functions that deal with multiple types in a consistent manner, using if statements and type queries.
Here is a function that returns the last digit of an int, or the last item of a list.
1 2 3 4 5 6 7
def last(thing): if type(thing) == int: x = str(thing) k = int(x[-1]) return k elif type(thing) == list: return thing[-1]