First time answering, hope my help is good!
Firstly, you haven't really covered all the continuous points that satisfy our line as you have only shown that $(\pi,0)$ lies on it through substitution.
Secondly, try to avoid putting $\infty$ inside a real function ($\Bbb R^2$). This is because $\infty$ is defined to be larger than any real number, making it a concept that is undefined. Hence it is not a real number.
This is why we say that the gradient of a line parallel to the y-axis is undefined.
Additionally, from what we know:
\begin{aligned}
m = gradient &= \frac{rise}{run}
\end{aligned}
If we wanted to define the gradient of a line parallel to the y-axis, which is $\infty$:
"rise" can be whatever real number you wanna put in there except 0, and "run" is 0 because the line doesn't deviate along the x-axis.
This means that we can end up with representations such as:
\begin{aligned}
m=gradient=\frac{1}{0}=\frac{2}{0}=\frac{7}{0}=\frac{1982749816487134}{0}
\end{aligned}
i.e:
\begin{aligned}
m=gradient=1=2=7=1982749816487134
\end{aligned}
Which are all mathematically absurd. Hence, our line with infinite gradient is undefined because it cannot be concretely defined (for now!).
So coming back to your question from what we have just thought about, it doesn't seem to be appropriate to define a vertical line in the form $y=mx+c$ where $m=\infty$ as $\infty$ does not make our function real. Even though we know very well that it is the general formula for most cases of straight lines.
Instead, we have a special case of a straight line where the gradient $m$ is undefined, where the formula for a straight line is no longer appropriate.
Here, we should focus on what is common with all the points that lie on a line parallel to the y-axis. For instance, with the problem that your teacher gave you: "define the equation of a line parallel to the y-axis passing through $(\pi,0)$" It could help to draw this out.
image is here
Here we can see that on our straight line passing through $(\pi,0)$, there are other points $(\pi,2),(\pi,3),(\pi,4),(\pi,5),$ and even $(\pi,-1)$.
We now have to define the equation of a line that holds true for all continuous points on that line, and yes, it can be independent to either the $x$ coordinates or the $y$ components. (But not both!!)
So if we proposed that the line containing all the points was $x=\pi$, we can show that it holds true by subbing in the $x$ component of each point:
- Subbing in $(\pi,0)$ into $x=\pi$ gives $\pi=\pi$ which is true.
- Subbing in $(\pi,-1)$ into $x=\pi$ gives $\pi=\pi$ which is true.
- Subbing in $(\pi,2)$ into $x=\pi$ gives $\pi=\pi$ which is true.
.
.
.
and so on.
This is why the answer that your teacher gave you is $x=\pi$.
Notice how we didn't even have to use the $y$ component of each coordinate!