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

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.

Hint ...

# binary for denary 9
bn = '1001'
dn = int(bn, 2)
print(dn)  # 9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.