write a function code on python