Why is this function continuous? (Topology) Consider a space $Y = (\mathbb R,\mathcal F)$, where $U$ is element of $\mathcal F$ iff $U$ is empty or $U$ contains the number $1$. (It can be proven that $Y$ is topological space).
Let $y_1,y_2$ be element of $Y$. Why is this function continuous?
$$ \begin{aligned}
f \colon [0,1] &\to Y \\
t &\mapsto \left\{
\begin{aligned}
y_1 \quad &\text{if}~ t = 0 \\
1 \quad &\text{if}~ 0 < t < 1 \\
y_2 \quad &\text{if}~ t = 1 \\
\end{aligned} \right.
\end{aligned}$$
 A: the pre-image of any nonempty open set in $Y$ must be one of $[0,1), (0,1)$ or $(0,1]$, since all of these are open in the usual topology for the closed unit interval $I$, the pre-image of any open set in $Y$ is open in $I$. but this is the condition for continuity.
(a few remarks added in response to comments and OP's request for clarification)
in reading math we frequently see confessions like: "this abuse of notation should cause no difficulties..." hmmm.
one of the most frequent abuses of notation is the use, for a mapping $f$ of the symbol $f^{-1}$. this has a clear meaning only when $f$ is both surjective and injective. otherwise the inverse function exponent $^{-1}$ conveniently avoids mentioning the fact, which might easily bewilder those new to the subject, that we are in fact dealing with a contravariant functor from the category of sets to its subcategory of powersets.
with the usual notation $\mathfrak{P}(A)$ for the operation of forming the powerset, then if we have a function $f:A \rightarrow B$ then under the action of the (more familiar) covariant powerset functor we have:
$$
\mathfrak{P}(f): \mathfrak{P}(A) \rightarrow \mathfrak{P}(B) \\
$$
defined by 
$$
\forall \mathbb{a} \in \mathfrak{P}(\mathbb{a}),\; \mathfrak{P}(f)(\mathbb{a}) = \bigcup_{a \in \mathbb{a}} \{f(a)\}
$$
this is very natural for our minds to think about, so the categoric underpinning is left aside as excess baggage. this shows, for example, in refusing to use a notation which clearly distinguishes $f$ and $\mathfrak{P}(f)$ or in the way the set-forming operator $\{\dots\}$ would usually be omitted from the union on the right. the identification with an element $x$ of $A$ with the corresponding singleton set $\{a\}$ in  $\mathfrak{P}(A)$ is easy and does not cause much trouble at an elementary level. 
the contravariant powerset functor, which we may denote here by $\mathfrak{P}^{-1}$ for emphasis, takes each set to its powerset as before, but its effect on functions is different. in fact we have:
$$\mathfrak{P}^{-1}(f):\mathfrak{P}(B) \rightarrow \mathfrak{P}(A)$$
a reversal of direction flagged by the prefix contra-. its action is defined by:
$$
\forall \mathbb{b} \in \mathfrak{P}(B),\; \mathfrak{P}^{-1}(f)(\mathbb{b}) = \bigcup_{b \in \mathbb{b}} \{a \in A \mid f(a)=b\}
$$
so typically we use the notation $f^{-1}$ as a convenient abbreviation for $\mathfrak{P}^{-1}(f)$.
as an example of the utility of this more precise way of looking at the matter, note that we may say $f:A \rightarrow B $ is surjective iff 
$$ \forall \mathbb{b} \in \mathfrak{P}(B), \;f^{-1}(\mathbb{b}) = \emptyset \rightarrow \mathbb{b} = \emptyset  $$
also note that a topology on a set $A$ is actually just a single element of the set $\mathfrak{P}^2(A)$, as should be clear from its description as a family of subsets of $A$.
A: There is an equivalent definition of continuity: a function $f: X\to Y$ between topological spaces is continuous at $x$ if there for any neighbourhood $V$ of $f(x)$ exists a neighbourhood $U$ of $x$ such that $f(U) \subseteq V$. The function is continuous if it is continuous at every $x\in X$.
In your case:
$t\neq 0,1:$ then $f(t) = 1$. Around any such $t$ we choose $U=(0,1)$ and $f(U)=1$.
$t=0:$ choose any open set $V$ around $y_1$. Then $f([0,1))\subseteq V$ since every open set contains $1$. 
$t=1:$ basically the same as for $t=0$.
