I am trying to display all the binary numbers which are divisible by 5 and I am able to successfully show them. But the output is in decimal format even though I have converted them to base 2 (binary).
My code -
user_input = raw_input("Enter three numbers separated by commas: ")
input_list = user_input.split(',')
decimal_list=[]
binary_list=[]
for i in input_list:
decimal_list.append(int(i,2))
print decimal_list
for x in decimal_list:
if x%5==0:
binary_list.append(int(str(x),10))
print binary_list
My input
0000,0001,0010,0011,0100,0101,0110,0111,1000
Output -
[0, 1, 2, 3, 4, 5, 6, 7, 8]
[0, 5]
Why do I get [0,5] instead of [0000,0101] ? I did convert them back to binary using (int(str(x),10))