May-03-2021, 06:48 AM
If you don't want to import, then you'll have to code it up.
Use len(str) to find the length of each of the elements in each column. Then use format strings to print each of the elements from that column in the correct length.
Use len(str) to find the length of each of the elements in each column. Then use format strings to print each of the elements from that column in the correct length.
formats = ["<20", 10, 5] data = [15, "Hello", "/bin/sh"] print("".join(f"| {d:{f}}" for d,f in zip(data,formats)))
Output:| 15 | Hello | /bin/sh