So essentially I'm prompting the user for two binary numbers. How can I add these together? I don't know how to get the 0b in front the the original input. If there is an easier way to do it, please let me know.

#Prompt the user for two binary numbers
bin1 = raw_input("Please enter a binary number: ")
bin2 = raw_input("Please enter another binary number: ")

binstr1 = str(bin1)
binstr2 = str(bin2)


#Check to verify that the user input two binary numbers
while '1' and '0' in binstr1, binstr1:
print str(binstr1)
else:
binstr1 = raw_input("You did not enter a binary number, Please try again: ")

This is what I have so far, but it doesn't work and have hit a wall.

use the inbuilt function bin to convert decimal numbers to binary

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.