 <p>You start with <code>num = 0</code>. You then set <code>temp = num</code>, so <code>temp</code> is zero. Thus your <code>while temp &gt; 0</code> loop never runs, and so nothing is ever added to <code>rev</code>. So when you try to use <code>join</code>, it just joins an empty list and produces an empty string.</p> <p>How to fix this is unclear, since you don't say what you want the code to do.</p>