To convert a number from base 2 to base 8 in Python, we can use the following algorithm:
Here's the Python code that implements the above algorithm:
main.py339 chars13 lines
Let's test the function with an example:
main.py71 chars3 lines
So the binary number 110101101
is converted to base 8 as 655
.
gistlibby LogSnag