In general, you can't do that. You have one equation and two unknowns (not three, since $d$ is uniquely determined by $n$ and $e$, even if actually computing it without knowing the factors of $n$ is difficult), so the solution will in general not be unique.
Of course, you could guess that $e$ might be one of the common values (e.g. 3 or 65537) and try to solve for $n$. But that only works if you guess the right $e$. And even if you do manage to determine $n$ this way, you'll still have to factor $n$ to be able to calculate $d$.
As for your code, it has many mistakes. I have no idea why you're setting
n = enc+1 or
e = k * n, for example — neither of those make any sense whatsoever. It looks as if you may be missing some fairly basic knowledge of either Python programming or the mathematics behind RSA.
As I can't really tell from just your code what it is that you might be missing, all I can suggest is finding some good tutorials and revising the basics. And maybe ask for help from your instructor / TA / tutor / etc., if you have one available.