I’m doing some formatted table printing, and I was wondering how i could do something like this, I think it’s a situation for lambda, but I’ve never used it before so I’m not sure 🙂
print "{:^{}}|"*(self.size).format(for i in range(self.size),6)
# self size is assumed to be 5 in this example, doesn't work, something along this line is needed though
Basically, do this(below) but in a cleaner way. PS. i know the below example doesn’t work, but you get my drift
print "{:^{}}" * 5 .format(humangrid[0][0],4,humangrid[0][1],4,humangrid[0][2],4,humangrid[0][3],4,humangrid[0][4],4,
Thanks!
Here’s my best guess:
If you really want to do it with a single call to
string.format():