0
def main():
    decimal=int(input('pleas enter a binary sequence: '))
   
    number=binaryConvert(decimal)
    print("Contert to decimal: ", number)


def binaryConvert(decimal):
   
    if decimal == 0 :
        return '0'
    elif decimal==1:
        return '1'
    
    
    
    number=''
    while decimal == '1' and decimal == '0' :
        number=str(decimal%2)+ number
        number=number
        
        
    
main()

but i did work well with me
so could u fix or find where is my mistake

Edited by vegaseat: added code tags

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by vegaseat
0

This statement will never be true

while decimal == '1' and decimal == '0' :
# ---- and this statement is meaningless
number=number

And str(decimal) will replace the binaryConvert() function. Also, press the code button to include your code in a readable (properly indented) form.

Edited by woooee: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.