ASCII Code Table Converter

  • Share this:

Code introduction


Converts each character in the input string to its ASCII code and displays it in a tabular format. Each ASCII code takes a fixed width, default is 10.


Technology Stack : String (str), built-in function (ord)

Code Type : String processing

Code Difficulty : Intermediate


                
                    
def ascii_table(text, width=10):
    table = ""
    for char in text:
        table += f"{ord(char):{width}d} "
    return table.strip()