Nov-26-2020, 04:53 PM
It's because you're passing in two different data types,
There's no right way to do this. Shrinking the size as small as possible helps. Changing the ints to strs works okay, but you lose the numeric alignment. For small numbers this is okay, but if you have a mix of sizes, it's very confusing.
int
and str
, and the default for format is to left-justify strings, but right-justify numbers. So they end up on the opposite side.There's no right way to do this. Shrinking the size as small as possible helps. Changing the ints to strs works okay, but you lose the numeric alignment. For small numbers this is okay, but if you have a mix of sizes, it's very confusing.
list_a=[[1,2,3,4,5], ['d','h','f','s','g']] #a=0, a=1,a=2, a=3, a=4,a=5 for row in list_a: print("{:15} {:15} {:15} {:15}{:15} ".format(*(str(x) for x in row)))
Output:1 2 3 4 5
d h f s g