Search this website

Simple script to convert binary to decimal in python

No comments
Here is a simple code to convert binary numbers to decimal ,I do not handle if the user enter a letter or decimal numbers ,it is just simple to do the purpose

sum=0
counter=0
l=[]
userInput=input("Enter binary number : ")
userInput[::-1]
for i in userInput:
    sum=sum+(int(i)*pow(2,counter))
    counter=counter+1
print(sum)

No comments :

Post a Comment