Even if you walk on a flat ground, you spend some energy related to walking. This is because the energy you spend lifting your feet, is not returned to your body when the foot is lowered, but rather turned into heat.
When you walk up a mountain, you still need to spend similar energy just lifting and lowering your feet, but, in addition, with each step, you have to spend some energy or perform some work to raise the COG and, therefore, the potential energy of your body.
This additional work, performed through the duration of the walk and contributing to the potential energy of your body, does not depend on the path you take - it is fully defined by the difference in elevation between the starting and the finishing points.
So, your teacher is right saying that the total work you expend walking up a mountain depends on a path you take. It is not in conflict with the statement that the work needed to change the potential energy of your body does not.