s1 = "id, name, class, gender, age, height, weight, pullup_count, pullup_score, hanging_count, hanging_score, pushup_count, pushup_score, situp_count, situp_score, running_count, running_score, run_bf_count, run_bf_score, final_score" s1 = "id, name, band_id, class, gender, age, height, weight, bmi, pbf" words = s1.split(", ") for word in words: print(word.upper(), "=", '"{}"'.format(word)) print("[{}]".format(", ".join([word.upper() for word in words])))