Can you write the same function in Python and explain the difference between the code?