How do I improve this code? (assignment tagged below)

As you can see, this cannot be understood as posted.

Follow the advice here. You can probably edit your original post to match, rather than post again.