ASCII Table Generator for Strings

  • Share this:

Code introduction


The function takes a string as input and creates an ASCII table, which includes the ASCII values and characters themselves from the string.


Technology Stack : String, formatted output

Code Type : Function

Code Difficulty :


                
                    
def ascii_table(string):
    """
    Generate a simple ASCII table from a string.
    """
    ascii_art = ""
    for char in string:
        ascii_art += f"{ord(char):4d} -> {char}\n"
    return ascii_art