write_code function

Write code based on user's input