General Motors (GM) Interview Question

implement a function in Python