Wrote the code for the assignment