Why is there a b in the binary code?

Hello, this might be a weird question but I noticed after ex23 that python in the shell can only read binary numbers if it has a b between the first and second character, like:
0b1000100 and such y’know.

I was wondering why is that, why specifically there and why does it need the b?

You have to provide some hint to the interpreter as to which number system you are about to use if it’s not the decimal system. 0b is the prefix for binary numbers, but there’s also 0x for hexadecimal numbers and perhaps even more.

1 Like

Now I’m off to research those hex numbers haha
Thank you!!

A free service run by Zed A. Shaw for learncodethehardway.org.