Create table from dictionary python
I was looking for a solution with unknown columns width to print a database table. So here it is: Show
Sample:
Output:
In Psycopg context, you can use it this way:
If you need a variant for multi-lines rows, here it is:
Sample:
Output:
Without View Discussion Improve Article Save Article View Discussion Improve Article Save Article 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
Output NAME AGE COURSE Samuel 21 Data Structures Richie 20 Machine Learning Lauren 21 OOPS with java Method 2: Displaying by using a matrix format Python3
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
Output NAME AGE COURSE Samuel 21 Data Structures Richie 20 Machine Learning Lauren 21 OOPS with Java |