Python program to print the dictionary in table format Last Updated : 06 Sep, 2024 Comments Improve Suggest changes Like Article Like Report Given a Dictionary. The task is to print the dictionary in table format.Examples:Input: {1: ["Samuel", 21, 'Data Structures'], 2: ["Richie", 20, 'Machine Learning'], 3: ["Lauren", 21, 'OOPS with java'], }Output: NAME AGE COURSE Samuel 21 Data Structures Richie 20 Machine Learning Lauren 21 OOPS with java Method 1: Displaying results by iterating through values. Python3 # Define the dictionary dict1 = {} # Insert data into dictionary dict1 = {1: ["Samuel", 21, 'Data Structures'], 2: ["Richie", 20, 'Machine Learning'], 3: ["Lauren", 21, 'OOPS with java'], } # Print the names of the columns. print("{:<10} {:<10} {:<10}".format('NAME', 'AGE', 'COURSE')) # print each data item. for key, value in dict1.items(): name, age, course = value print("{:<10} {:<10} {:<10}".format(name, age, course)) OutputNAME AGE COURSE Samuel 21 Data Structures Richie 20 Machine Learning Lauren 21 OOPS with java Method 2: Displaying by using a matrix format Python3 # define the dictionary dict1 = {} # insert data into dictionary dict1 = {(0, 0): 'Samuel', (0, 1): 21, (0, 2): 'Data structures', (1, 0): 'Richie', (1, 1): 20, (1, 2): 'Machine Learning', (2, 0): 'Lauren', (2, 1): 21, (2, 2): 'OOPS with Java' } # print the name of the columns explicitly. print(" NAME ", " AGE ", " COURSE ") # Iterate through the dictionary # to print the data. for i in range(3): for j in range(3): print(dict1[(i, j)], end=' ') print() Output NAME AGE COURSE Samuel 21 Data structures Richie 20 Machine Learning Lauren 21 OOPS with Java Method 3: Displaying by using zip format Python3 # define the dictionary dict1 = {} # insert data into dictionary. dict1 = {'NAME': ['Samuel', 'Richie', 'Lauren'], 'AGE': [21, 20, 21], 'COURSE': ['Data Structures', 'Machine Learning', 'OOPS with Java']} # print the contents using zip format. for each_row in zip(*([i] + (j) for i, j in dict1.items())): print(*each_row, " ") OutputNAME AGE COURSE Samuel 21 Data Structures Richie 20 Machine Learning Lauren 21 OOPS with Java Comment More infoAdvertise with us Next Article Python program to print the dictionary in table format K KaranGupta5 Follow Improve Article Tags : Python Python Programs python-dict Practice Tags : pythonpython-dict Similar Reads How to Print a Dictionary in Python Python Dictionaries are the form of data structures that allow us to store and retrieve the key-value pairs properly. While working with dictionaries, it is important to print the contents of the dictionary for analysis or debugging.Example: Using print FunctionPython# input dictionary input_dict = 3 min read How to Print Dictionary Keys in Python We are given a dictionary and our task is to print its keys, this can be helpful when we want to access or display only the key part of each key-value pair. For example, if we have a dictionary like this: {'gfg': 1, 'is': 2, 'best': 3} then the output will be ['gfg', 'is', 'best']. Below, are the me 2 min read Dictionary Programs involving Lists - Python Dictionaries and lists are two of the most commonly used data structures in Python, and often, we need to work with both together. Whether it's storing lists as dictionary values, converting lists into dictionaries, filtering dictionary data using lists, or modifying dictionary values dynamically, P 2 min read Python - Print dictionary of list values In this article, we will explore various ways on How to Print Dictionary in Python of list values. A dictionary of list values means a dictionary contains values as a list of dictionaries in Python. Example: {'key1': [{'key1': value,......,'key n': value}........{'key1': value,......,'key n': value} 4 min read How to Initialize Dictionary in Python In Python dictionary, each key is unique and we can store different data types as values. The simplest and most efficient method to initialize a dictionary is using curly braces {}. This is the easiest and most common way to create a dictionary. We can use curly braces '{} ' and separate the keys an 2 min read Like