Why is my decimal to binary program returning the value backwards and in a table format?
<p>I'm using python 3.5.2 to make this program. It'supposed to take any decimal number and convert it to binary.</p>

<pre><code>number = int(input('Enter a number in base 10: '))
base2 = ''
while(number &gt; 0):
     rem = number % 2
     number = number // 2
     base2 = srt(number) + str(rem)
     print(rem)
#This was to prevent the end text from sticking to the print
input('\nEnter to end')
</code></pre>

<p>It returns the correct values, but backwards and in a column and I don't know why.</p>

<p>Your code prints the lowest bit of remaining number on separate lines so that's why you see them in reverse order. You could change your code to store bits to an array and then after the loop print them in reverse order:</p>

<pre><code>number = int(input('Enter a number in base 10: '))
base2 = []
while(number &gt; 0):
     base2.append(str(number % 2))
     number = number // 2

print(''.join(reversed(base2)))
</code></pre>

<p>Python also has built-in method <a href="https://docs.python.org/3.5/library/functions.html#bin" rel="nofollow"><code>bin</code></a> than can do the conversion for you:</p>

<pre><code>&gt;&gt;&gt; bin(10)
'0b1010'
</code></pre>

python binary decimal converter data-conversion