Python oct() built-in function

From the Python 3 documentation

Convert an integer number to an octal string prefixed with “0o”. The result is a valid Python expression. If x is not a Python int object, it has to define an __index__() method that returns an integer.

Introduction

The oct() function converts an integer into its octal representation. The resulting string is prefixed with “0o” to indicate that it’s an octal number.

Examples

Here are a few examples of how to use oct():

# Convert integers to octal
print(oct(8))
print(oct(10))
print(oct(100))
print(oct(1))
print(oct(1000))
0o10
0o12
0o144
0o1
0o1750