from stack import stack
s=stack()
def convert_int_to_bin(dec_num):
if dec_num <1:
q=’’
while not s.is_empty():
q+=str(s.pop())
return q
else:
w=dec_num%2
s.push(w)
a=int(dec_num/2)
return convert_int_to_bin(a)
from stack import stack
s=stack()
def convert_int_to_bin(dec_num):
if dec_num <1:
q=’’
while not s.is_empty():
q+=str(s.pop())
return q
else:
w=dec_num%2
s.push(w)
a=int(dec_num/2)
return convert_int_to_bin(a)
Hi @vvs_rohith,
I tried the following code provided by you but it worked perfectly fine. Make sure your indentation is correct.
from stack import Stack
s = Stack()
def convert_int_to_bin(dec_num):
if dec_num < 1:
q = ''
while not s.is_empty():
q+=str(s.pop())
return q
else:
w=dec_num%2
s.push(w)
a=int(dec_num/2)
return convert_int_to_bin(a)