the code would still try to print a last element. also rearrange the loop to avoid code duplication and use delta-1 spaces after the comma.