Is the set $E=\{0.a_1a_2... \in \mathbb{R}\mid a_i= 4 \text{ or } a_i=7\}$ dense, compact or perfect? I want to check my reasoning, I found that it's not dense but it's compact and perfect.
$1$- It's not dense for 1 is neither in the set of a limit point of it.
$2$- It's compact because it's both bounded ( clearly ) and closed. To show it's a closed set, I used the theorem which states that  if $A$ is a bounded above subset of $\mathbb{R}$ and $SupA \in A$ then $A$ is closed.
Here, it's clear that $SupE=0.7777777... \text{(all digits are 7's)}$ and clearly , this real number lies in $E$
So $E$ is both closed and bounded hence, compact
$3$-To show it's perfect, I show that every $x\in E$ is a limit point of $E$.
let  $x=0.x_1x_2x_3...$, 
and  $(a_1,a_2)$ be a neighborhood of $x$ where $a_2=0.h_1h_2....$
Assuming that $x\ne supE$, 
Let $r$ be the smallest positive integer s.t. $x_i=h_i$ for $i\le r$.
If $h_r=4$ then $x_{r+1}\ge 5$ and if $h_r=7$ then $x_{r+1}\ge 8$. define $y=0.x_1x_2...x_{r}x_{r+1}Sx_{r+3}x_{r+4}...$ where $S=4$ if $x_{r+2}=7$ and $S=7$ otherwise.
It's clear that $x\ne y$ and $y\in E$ and $y\in (a_1,a_2)$ So   the neighborhood $(a_1,a_2)$ intersects $E$ in a point $y$ different than $x$ hence, x is a limit point of $E$
If $x=supE$ , we use the same process but this time we use $a_1$ instead of $a_2$.
So $E$ is perfect and we're done.
My question is, Is my reasoning right? are there any logical gaps? If no, Any better solutions? 
 A: To show that $E$ is open, let $x\in\Bbb R\setminus E$, and show how to construct an open interval around $x$ that misses $E$. You can do this in terms of the decimal expansion of $x$. Say that the expansion is $0.d_1d_2\ldots\;$. Let $n\in\Bbb Z^+$ be minimal such that $d_n\notin\{4,7\}$. If $d_n=5$, say, let $a$ and $b$ have the expansions $0.d_1\ldots d_{n-1}4$ and $0.d_1\ldots d_{n-1}6$, respectively, and consider the interval $(a,b)$. I’ll leave it to you to figure out how to modify this idea when $d_n$ is $0$ or $9$.
Clearly $E$ is bounded, being a subset of $\left[\frac49,\frac79\right]$, so once you know that it’s closed, you know that it’s compact.
The idea behind your argument that every point of $E$ is a limit point of $E$ is fine, but there are some glitches in the argument as you’ve written it. First, I’m pretty sure that you meant to make $r$ the largest positive integer such that $x_i=h_i$ for all $i\le r$; then $r+1$ is the index of the first place in which the two expansions differ. (You actually assumed in your next paragraph that $r$ was the first place at which they differed, and in fact it’s a little easier to work with that, so I’d let $$r=\min\{i\in\Bbb Z^+:x_i\ne h_i\}\;.$$
At the next step you reversed the roles of $x_r$ and $h_r$. You want to say that if $x_r=4$, then $h_r\ge 5$, and if $x_r=7$, then $h_r\ge 8$. Now you can argue as follows. If there is an $s>r$ such that $x_s=4$, replace it with a $7$, let $x'$ be the resulting number, and show that $x'\in E\cap(x,a_2)$. Otherwise, $x_i=7$ for all $i>r$. In that case $x$ is not a limit point of $E$ from the right, and you should try to show (in very similar fashion) that $E\cap(a_1,x)\ne\varnothing$. Here you’ll find that you’re okay unless the expansion of $x$ ends in an infinite string of $4$s.

As I mentioned in the comments, this is really just a Cantor set. It can be constructed in the same fashion as the familiar middle-thirds Cantor set $C$ by deleting middle open intervals, though they aren’t thirds. We start with the closed interval $\left[\frac49,\frac79\right]$. At the first step we remove $(0.4\overline{7},0.7\overline{4})$. At the next step we remove $(0.44\overline{7},0.47\overline{4})$ and $(0.74\overline{7},0.77\overline{4})$, and we continue in this fashion.
Alternatively one can show that if we map $E$ to $C$ by changing each $4$ and $7$ in the decimal expansion of $x\in E$ to $0$ and $2$, respectively, and interpret the resulting expression as the ternary expansion of a real number, the map is a homeomorphism.
